diff --git a/type-script-helper-1.3.15.vsix b/type-script-helper-1.3.15.vsix new file mode 100644 index 0000000..2e7f3d6 Binary files /dev/null and b/type-script-helper-1.3.15.vsix differ diff --git a/type-script-helper/README.md b/type-script-helper/README.md index f0357f8..5ce8f8b 100644 --- a/type-script-helper/README.md +++ b/type-script-helper/README.md @@ -109,4 +109,9 @@ Quick Fix - Instance Field to Calisthenics ----------------------------------------------------------------------------------------------------------- Split by Space Reverse Join Sort lines (ascending, case sensitive) -PathWithoutBracketsSingularized \ No newline at end of file +PathWithoutBracketsSingularized + +## 1.3.15 +----------------------------------------------------------------------------------------------------------- + +Distinct list \ No newline at end of file diff --git a/type-script-helper/package-lock.json b/type-script-helper/package-lock.json index 7a15dba..bf1eab8 100644 --- a/type-script-helper/package-lock.json +++ b/type-script-helper/package-lock.json @@ -1,12 +1,12 @@ { "name": "type-script-helper", - "version": "1.3.13", + "version": "1.3.15", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "type-script-helper", - "version": "1.3.13", + "version": "1.3.15", "devDependencies": { "@types/glob": "^7.1.1", "@types/mocha": "^5.2.7", @@ -781,9 +781,9 @@ } }, "node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" @@ -812,9 +812,9 @@ } }, "node_modules/mocha": { - "version": "9.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.0.tgz", - "integrity": "sha512-kNn7E8g2SzVcq0a77dkphPsDSN7P+iYkqE0ZsGCYWRsoiKjOt+NvXfaagik8vuDa6W5Zw3qxe8Jfpt5qKf+6/Q==", + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.2.tgz", + "integrity": "sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g==", "dev": true, "dependencies": { "@ungap/promise-all-settled": "1.1.2", @@ -830,9 +830,9 @@ "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", - "minimatch": "3.0.4", + "minimatch": "4.2.1", "ms": "2.1.3", - "nanoid": "3.2.0", + "nanoid": "3.3.1", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", @@ -907,6 +907,18 @@ "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": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -920,9 +932,9 @@ "dev": true }, "node_modules/nanoid": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", - "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", + "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==", "dev": true, "bin": { "nanoid": "bin/nanoid.cjs" @@ -1246,7 +1258,7 @@ }, "node_modules/typescript": { "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==", "dev": true, "bin": { @@ -1999,9 +2011,9 @@ } }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "requires": { "brace-expansion": "^1.1.7" @@ -2023,9 +2035,9 @@ } }, "mocha": { - "version": "9.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.0.tgz", - "integrity": "sha512-kNn7E8g2SzVcq0a77dkphPsDSN7P+iYkqE0ZsGCYWRsoiKjOt+NvXfaagik8vuDa6W5Zw3qxe8Jfpt5qKf+6/Q==", + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.2.tgz", + "integrity": "sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g==", "dev": true, "requires": { "@ungap/promise-all-settled": "1.1.2", @@ -2041,9 +2053,9 @@ "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", - "minimatch": "3.0.4", + "minimatch": "4.2.1", "ms": "2.1.3", - "nanoid": "3.2.0", + "nanoid": "3.3.1", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", @@ -2092,6 +2104,15 @@ "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": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -2107,9 +2128,9 @@ "dev": true }, "nanoid": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", - "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", + "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==", "dev": true }, "normalize-path": { @@ -2336,7 +2357,7 @@ }, "typescript": { "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==", "dev": true }, diff --git a/type-script-helper/package.json b/type-script-helper/package.json index 8d8b489..08b1dd4 100644 --- a/type-script-helper/package.json +++ b/type-script-helper/package.json @@ -4,7 +4,7 @@ "description": "Helper for VS Code in TypeScript", "publisher": "IFX", "repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper", - "version": "1.3.14", + "version": "1.3.15", "engines": { "vscode": "^1.40.0" }, @@ -13,13 +13,14 @@ ], "main": "./out/extension.js", "activationEvents": [ - "onCommand:open-in-new-window.open", + "onCommand:open-in-new-window.open", "onCommand:promiseLinesHelper.codeGeneratorQuickPick", "onCommand:readOnlyLinesHelper.searchGoogle", "onCommand:replaceLinesHelper.addCSharpComment", "onCommand:replaceLinesHelper.addVBComment", "onCommand:replaceLinesHelper.convertToRegularExpression", "onCommand:replaceLinesHelper.cutEachLine", + "onCommand:replaceLinesHelper.distinctLines", "onCommand:replaceLinesHelper.expandSql", "onCommand:replaceLinesHelper.listToListFamily", "onCommand:replaceLinesHelper.listToListWrappedComma", @@ -67,6 +68,10 @@ "command": "replaceLinesHelper.cutEachLine", "title": "Cut each line after |||" }, + { + "command": "replaceLinesHelper.distinctLines", + "title": "Distinct Lines" + }, { "command": "replaceLinesHelper.expandSql", "title": "Expand Sql" @@ -133,7 +138,7 @@ } ], "menus": { - "explorer/context": [ + "explorer/context": [ { "command": "open-in-new-window.open", "group": "openInNewWindowGroup" diff --git a/type-script-helper/src/extension.ts b/type-script-helper/src/extension.ts index b2176d3..8d8a38b 100644 --- a/type-script-helper/src/extension.ts +++ b/type-script-helper/src/extension.ts @@ -9,7 +9,7 @@ import * as promiseLinesHelper from './promiseLinesHelper'; // your extension is activated the very first time the command is executed export function activate(context: vscode.ExtensionContext) { - const openCommand = 'open-in-new-window.open'; + const openCommand = 'open-in-new-window.open'; // Use the console to output diagnostic information (console.log) and errors (console.error) // This line of code will only be executed once when your extension is activated @@ -43,6 +43,7 @@ export function activate(context: vscode.ExtensionContext) { vscode.commands.registerCommand('replaceLinesHelper.addVBComment', replaceLinesHelper.addVBComment), vscode.commands.registerCommand('replaceLinesHelper.convertToRegularExpression', replaceLinesHelper.convertToRegularExpression), 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.listToListFamily', replaceLinesHelper.listToListFamily), vscode.commands.registerCommand('replaceLinesHelper.listToListWrappedComma', replaceLinesHelper.listToListWrappedComma), diff --git a/type-script-helper/src/replaceLinesHelper.ts b/type-script-helper/src/replaceLinesHelper.ts index 00ae61c..eb7c176 100644 --- a/type-script-helper/src/replaceLinesHelper.ts +++ b/type-script-helper/src/replaceLinesHelper.ts @@ -8,6 +8,7 @@ enum LinesAction { addVBComment, convertToRegularExpression, cutEachLine, + distinctLines, expandSql, listToListFamily, listToListWrappedComma, @@ -365,6 +366,15 @@ function cutEachLineLogic(lines: string[]): void { 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[]) { return textEditor.edit(editBuilder => { const range = new vscode.Range(startLine, 0, endLine, textEditor.document.lineAt(endLine).text.length); @@ -390,6 +400,7 @@ function linesFunction(linesAction: LinesAction): Thenable | undefined case LinesAction.addVBComment: { addVBCommentLogic(lines); break; } case LinesAction.convertToRegularExpression: { lines = convertToRegularExpressionLogic(lines); break; } case LinesAction.cutEachLine: { cutEachLineLogic(lines); break; } + case LinesAction.distinctLines: { distinctLinesLogic(lines); break; } case LinesAction.expandSql: { expandSqlLogic(lines); break; } case LinesAction.listToListFamily: { listToListFamilyLogic(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 convertToRegularExpression = () => linesFunction(LinesAction.convertToRegularExpression); export const cutEachLine = () => linesFunction(LinesAction.cutEachLine); +export const distinctLines = () => linesFunction(LinesAction.distinctLines); export const expandSql = () => linesFunction(LinesAction.expandSql); export const listToListFamily = () => linesFunction(LinesAction.listToListFamily); export const listToListWrappedComma = () => linesFunction(LinesAction.listToListWrappedComma);