1.3.15 Distinct Lines

This commit is contained in:
Mike Phares 2023-01-25 15:55:07 -07:00
parent 85fa349968
commit 83a014c201
6 changed files with 75 additions and 31 deletions

Binary file not shown.

View File

@ -110,3 +110,8 @@ Quick Fix - Instance Field to Calisthenics
Split by Space Reverse Join Sort lines (ascending, case sensitive) Split by Space Reverse Join Sort lines (ascending, case sensitive)
PathWithoutBracketsSingularized PathWithoutBracketsSingularized
## 1.3.15
-----------------------------------------------------------------------------------------------------------
Distinct list

View File

@ -1,12 +1,12 @@
{ {
"name": "type-script-helper", "name": "type-script-helper",
"version": "1.3.13", "version": "1.3.15",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "type-script-helper", "name": "type-script-helper",
"version": "1.3.13", "version": "1.3.15",
"devDependencies": { "devDependencies": {
"@types/glob": "^7.1.1", "@types/glob": "^7.1.1",
"@types/mocha": "^5.2.7", "@types/mocha": "^5.2.7",
@ -781,9 +781,9 @@
} }
}, },
"node_modules/minimatch": { "node_modules/minimatch": {
"version": "3.0.4", "version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
@ -812,9 +812,9 @@
} }
}, },
"node_modules/mocha": { "node_modules/mocha": {
"version": "9.2.0", "version": "9.2.2",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.0.tgz", "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.2.tgz",
"integrity": "sha512-kNn7E8g2SzVcq0a77dkphPsDSN7P+iYkqE0ZsGCYWRsoiKjOt+NvXfaagik8vuDa6W5Zw3qxe8Jfpt5qKf+6/Q==", "integrity": "sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@ungap/promise-all-settled": "1.1.2", "@ungap/promise-all-settled": "1.1.2",
@ -830,9 +830,9 @@
"he": "1.2.0", "he": "1.2.0",
"js-yaml": "4.1.0", "js-yaml": "4.1.0",
"log-symbols": "4.1.0", "log-symbols": "4.1.0",
"minimatch": "3.0.4", "minimatch": "4.2.1",
"ms": "2.1.3", "ms": "2.1.3",
"nanoid": "3.2.0", "nanoid": "3.3.1",
"serialize-javascript": "6.0.0", "serialize-javascript": "6.0.0",
"strip-json-comments": "3.1.1", "strip-json-comments": "3.1.1",
"supports-color": "8.1.1", "supports-color": "8.1.1",
@ -907,6 +907,18 @@
"js-yaml": "bin/js-yaml.js" "js-yaml": "bin/js-yaml.js"
} }
}, },
"node_modules/mocha/node_modules/minimatch": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz",
"integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==",
"dev": true,
"dependencies": {
"brace-expansion": "^1.1.7"
},
"engines": {
"node": ">=10"
}
},
"node_modules/mocha/node_modules/ms": { "node_modules/mocha/node_modules/ms": {
"version": "2.1.3", "version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
@ -920,9 +932,9 @@
"dev": true "dev": true
}, },
"node_modules/nanoid": { "node_modules/nanoid": {
"version": "3.2.0", "version": "3.3.1",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz",
"integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==",
"dev": true, "dev": true,
"bin": { "bin": {
"nanoid": "bin/nanoid.cjs" "nanoid": "bin/nanoid.cjs"
@ -1246,7 +1258,7 @@
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "3.9.10", "version": "3.9.10",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", "resolved": "http://localhost:4873/typescript/-/typescript-3.9.10.tgz",
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==",
"dev": true, "dev": true,
"bin": { "bin": {
@ -1999,9 +2011,9 @@
} }
}, },
"minimatch": { "minimatch": {
"version": "3.0.4", "version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dev": true, "dev": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
@ -2023,9 +2035,9 @@
} }
}, },
"mocha": { "mocha": {
"version": "9.2.0", "version": "9.2.2",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.0.tgz", "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.2.tgz",
"integrity": "sha512-kNn7E8g2SzVcq0a77dkphPsDSN7P+iYkqE0ZsGCYWRsoiKjOt+NvXfaagik8vuDa6W5Zw3qxe8Jfpt5qKf+6/Q==", "integrity": "sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g==",
"dev": true, "dev": true,
"requires": { "requires": {
"@ungap/promise-all-settled": "1.1.2", "@ungap/promise-all-settled": "1.1.2",
@ -2041,9 +2053,9 @@
"he": "1.2.0", "he": "1.2.0",
"js-yaml": "4.1.0", "js-yaml": "4.1.0",
"log-symbols": "4.1.0", "log-symbols": "4.1.0",
"minimatch": "3.0.4", "minimatch": "4.2.1",
"ms": "2.1.3", "ms": "2.1.3",
"nanoid": "3.2.0", "nanoid": "3.3.1",
"serialize-javascript": "6.0.0", "serialize-javascript": "6.0.0",
"strip-json-comments": "3.1.1", "strip-json-comments": "3.1.1",
"supports-color": "8.1.1", "supports-color": "8.1.1",
@ -2092,6 +2104,15 @@
"argparse": "^2.0.1" "argparse": "^2.0.1"
} }
}, },
"minimatch": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz",
"integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"ms": { "ms": {
"version": "2.1.3", "version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
@ -2107,9 +2128,9 @@
"dev": true "dev": true
}, },
"nanoid": { "nanoid": {
"version": "3.2.0", "version": "3.3.1",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz",
"integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==",
"dev": true "dev": true
}, },
"normalize-path": { "normalize-path": {
@ -2336,7 +2357,7 @@
}, },
"typescript": { "typescript": {
"version": "3.9.10", "version": "3.9.10",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", "resolved": "http://localhost:4873/typescript/-/typescript-3.9.10.tgz",
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==",
"dev": true "dev": true
}, },

View File

@ -4,7 +4,7 @@
"description": "Helper for VS Code in TypeScript", "description": "Helper for VS Code in TypeScript",
"publisher": "IFX", "publisher": "IFX",
"repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper", "repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper",
"version": "1.3.14", "version": "1.3.15",
"engines": { "engines": {
"vscode": "^1.40.0" "vscode": "^1.40.0"
}, },
@ -20,6 +20,7 @@
"onCommand:replaceLinesHelper.addVBComment", "onCommand:replaceLinesHelper.addVBComment",
"onCommand:replaceLinesHelper.convertToRegularExpression", "onCommand:replaceLinesHelper.convertToRegularExpression",
"onCommand:replaceLinesHelper.cutEachLine", "onCommand:replaceLinesHelper.cutEachLine",
"onCommand:replaceLinesHelper.distinctLines",
"onCommand:replaceLinesHelper.expandSql", "onCommand:replaceLinesHelper.expandSql",
"onCommand:replaceLinesHelper.listToListFamily", "onCommand:replaceLinesHelper.listToListFamily",
"onCommand:replaceLinesHelper.listToListWrappedComma", "onCommand:replaceLinesHelper.listToListWrappedComma",
@ -67,6 +68,10 @@
"command": "replaceLinesHelper.cutEachLine", "command": "replaceLinesHelper.cutEachLine",
"title": "Cut each line after |||" "title": "Cut each line after |||"
}, },
{
"command": "replaceLinesHelper.distinctLines",
"title": "Distinct Lines"
},
{ {
"command": "replaceLinesHelper.expandSql", "command": "replaceLinesHelper.expandSql",
"title": "Expand Sql" "title": "Expand Sql"

View File

@ -43,6 +43,7 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('replaceLinesHelper.addVBComment', replaceLinesHelper.addVBComment), vscode.commands.registerCommand('replaceLinesHelper.addVBComment', replaceLinesHelper.addVBComment),
vscode.commands.registerCommand('replaceLinesHelper.convertToRegularExpression', replaceLinesHelper.convertToRegularExpression), vscode.commands.registerCommand('replaceLinesHelper.convertToRegularExpression', replaceLinesHelper.convertToRegularExpression),
vscode.commands.registerCommand('replaceLinesHelper.cutEachLine', replaceLinesHelper.cutEachLine), vscode.commands.registerCommand('replaceLinesHelper.cutEachLine', replaceLinesHelper.cutEachLine),
vscode.commands.registerCommand('replaceLinesHelper.distinctLines', replaceLinesHelper.distinctLines),
vscode.commands.registerCommand('replaceLinesHelper.expandSql', replaceLinesHelper.expandSql), vscode.commands.registerCommand('replaceLinesHelper.expandSql', replaceLinesHelper.expandSql),
vscode.commands.registerCommand('replaceLinesHelper.listToListFamily', replaceLinesHelper.listToListFamily), vscode.commands.registerCommand('replaceLinesHelper.listToListFamily', replaceLinesHelper.listToListFamily),
vscode.commands.registerCommand('replaceLinesHelper.listToListWrappedComma', replaceLinesHelper.listToListWrappedComma), vscode.commands.registerCommand('replaceLinesHelper.listToListWrappedComma', replaceLinesHelper.listToListWrappedComma),

View File

@ -8,6 +8,7 @@ enum LinesAction {
addVBComment, addVBComment,
convertToRegularExpression, convertToRegularExpression,
cutEachLine, cutEachLine,
distinctLines,
expandSql, expandSql,
listToListFamily, listToListFamily,
listToListWrappedComma, listToListWrappedComma,
@ -365,6 +366,15 @@ function cutEachLineLogic(lines: string[]): void {
removeBlanks(lines); removeBlanks(lines);
} }
function distinctLinesLogic(lines: string[]): void {
for (let i = 0; i < lines.length; ++i) {
if (lines[i].trim() === '' || lines.indexOf(lines[i]) !== lines.lastIndexOf(lines[i])) {
lines.splice(i, 1);
i--;
}
}
}
function returnLines(textEditor: vscode.TextEditor, startLine: number, endLine: number, lines: string[]) { function returnLines(textEditor: vscode.TextEditor, startLine: number, endLine: number, lines: string[]) {
return textEditor.edit(editBuilder => { return textEditor.edit(editBuilder => {
const range = new vscode.Range(startLine, 0, endLine, textEditor.document.lineAt(endLine).text.length); const range = new vscode.Range(startLine, 0, endLine, textEditor.document.lineAt(endLine).text.length);
@ -390,6 +400,7 @@ function linesFunction(linesAction: LinesAction): Thenable<boolean> | undefined
case LinesAction.addVBComment: { addVBCommentLogic(lines); break; } case LinesAction.addVBComment: { addVBCommentLogic(lines); break; }
case LinesAction.convertToRegularExpression: { lines = convertToRegularExpressionLogic(lines); break; } case LinesAction.convertToRegularExpression: { lines = convertToRegularExpressionLogic(lines); break; }
case LinesAction.cutEachLine: { cutEachLineLogic(lines); break; } case LinesAction.cutEachLine: { cutEachLineLogic(lines); break; }
case LinesAction.distinctLines: { distinctLinesLogic(lines); break; }
case LinesAction.expandSql: { expandSqlLogic(lines); break; } case LinesAction.expandSql: { expandSqlLogic(lines); break; }
case LinesAction.listToListFamily: { listToListFamilyLogic(lines); break; } case LinesAction.listToListFamily: { listToListFamilyLogic(lines); break; }
case LinesAction.listToListWrappedComma: { listToListWrappedCommaLogic(lines); break; } case LinesAction.listToListWrappedComma: { listToListWrappedCommaLogic(lines); break; }
@ -415,6 +426,7 @@ export const addCSharpComment = () => linesFunction(LinesAction.addCSharpComment
export const addVBComment = () => linesFunction(LinesAction.addVBComment); export const addVBComment = () => linesFunction(LinesAction.addVBComment);
export const convertToRegularExpression = () => linesFunction(LinesAction.convertToRegularExpression); export const convertToRegularExpression = () => linesFunction(LinesAction.convertToRegularExpression);
export const cutEachLine = () => linesFunction(LinesAction.cutEachLine); export const cutEachLine = () => linesFunction(LinesAction.cutEachLine);
export const distinctLines = () => linesFunction(LinesAction.distinctLines);
export const expandSql = () => linesFunction(LinesAction.expandSql); export const expandSql = () => linesFunction(LinesAction.expandSql);
export const listToListFamily = () => linesFunction(LinesAction.listToListFamily); export const listToListFamily = () => linesFunction(LinesAction.listToListFamily);
export const listToListWrappedComma = () => linesFunction(LinesAction.listToListWrappedComma); export const listToListWrappedComma = () => linesFunction(LinesAction.listToListWrappedComma);