diff --git a/type-script-helper-1.2.5.vsix b/type-script-helper-1.2.5.vsix new file mode 100644 index 0000000..9af884a Binary files /dev/null and b/type-script-helper-1.2.5.vsix differ diff --git a/type-script-helper-1.2.6.vsix b/type-script-helper-1.2.6.vsix new file mode 100644 index 0000000..6b9cd36 Binary files /dev/null and b/type-script-helper-1.2.6.vsix differ diff --git a/type-script-helper-1.2.7.vsix b/type-script-helper-1.2.7.vsix new file mode 100644 index 0000000..8ff3625 Binary files /dev/null and b/type-script-helper-1.2.7.vsix differ diff --git a/type-script-helper-1.2.8.vsix b/type-script-helper-1.2.8.vsix new file mode 100644 index 0000000..ae9cbb6 Binary files /dev/null and b/type-script-helper-1.2.8.vsix differ diff --git a/type-script-helper/README.md b/type-script-helper/README.md index 2518eb0..9b72084 100644 --- a/type-script-helper/README.md +++ b/type-script-helper/README.md @@ -57,3 +57,13 @@ Added split(' group by ').join('\r\n GROUP BY '). ## Working with Markdown ### For more information + +### 1.2.4 +----------------------------------------------------------------------------------------------------------- + +## Search Google + +### 1.2.8 +----------------------------------------------------------------------------------------------------------- + +## Search Google (Read Only Lines Helper) diff --git a/type-script-helper/package.json b/type-script-helper/package.json index 02e6ed3..b32bd50 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.2.4", + "version": "1.2.8", "engines": { "vscode": "^1.40.0" }, @@ -13,43 +13,43 @@ ], "main": "./out/extension.js", "activationEvents": [ - "onCommand:helper.addCSharpComment", - "onCommand:helper.addVBComment", - "onCommand:helper.convertToRegularExpression", - "onCommand:helper.cutEachLine", - "onCommand:helper.expandSql", - "onCommand:helper.listToListFamily", - "onCommand:helper.listToListWrappedComma", - "onCommand:helper.prettySql", - "onCommand:helper.removeComment", - "onCommand:helper.searchGoogle", - "onCommand:helper.sortLength", - "onCommand:helper.sortNormal", - "onCommand:helper.unwrapSql", - "onCommand:helper.wrapSqlCSharp", - "onCommand:helper.wrapSqlVB" + "onCommand:readOnlyLinesHelper.searchGoogle", + "onCommand:replaceLinesHelper.addCSharpComment", + "onCommand:replaceLinesHelper.addVBComment", + "onCommand:replaceLinesHelper.convertToRegularExpression", + "onCommand:replaceLinesHelper.cutEachLine", + "onCommand:replaceLinesHelper.expandSql", + "onCommand:replaceLinesHelper.listToListFamily", + "onCommand:replaceLinesHelper.listToListWrappedComma", + "onCommand:replaceLinesHelper.prettySql", + "onCommand:replaceLinesHelper.removeComment", + "onCommand:replaceLinesHelper.sortLength", + "onCommand:replaceLinesHelper.sortNormal", + "onCommand:replaceLinesHelper.unwrapSql", + "onCommand:replaceLinesHelper.wrapSqlCSharp", + "onCommand:replaceLinesHelper.wrapSqlVB" ], "contributes": { "commands": [ - { "command": "helper.addCSharpComment", "title": "Add C# Comment" }, - { "command": "helper.addVBComment", "title": "Add VB Comment" }, - { "command": "helper.convertToRegularExpression", "title": "Convert to Regular Expression" }, - { "command": "helper.cutEachLine", "title": "Cut each line after |||" }, - { "command": "helper.expandSql", "title": "Expand Sql" }, - { "command": "helper.listToListFamily", "title": "List to list family (Kristy, Mike ...)" }, - { "command": "helper.listToListWrappedComma", "title": "List to list wrapped comma" }, - { "command": "helper.prettySql", "title": "Pretty Sql" }, - { "command": "helper.removeComment", "title": "Remove comment" }, - { "command": "helper.searchGoogle", "title": "Search Google" }, - { "command": "helper.sortLength", "title": "Sort by Length" }, - { "command": "helper.sortNormal", "title": "My Sort lines (ascending, case sensitive)" }, - { "command": "helper.unwrapSql", "title": "Un-wrap Sql" }, - { "command": "helper.wrapSqlCSharp", "title": "Wrap Sql for C#" }, - { "command": "helper.wrapSqlVB", "title": "Wrap Sql for VB" } + { "command": "readOnlyLinesHelper.searchGoogle", "title": "Search Google" }, + { "command": "replaceLinesHelper.addCSharpComment", "title": "Add C# Comment" }, + { "command": "replaceLinesHelper.addVBComment", "title": "Add VB Comment" }, + { "command": "replaceLinesHelper.convertToRegularExpression", "title": "Convert to Regular Expression" }, + { "command": "replaceLinesHelper.cutEachLine", "title": "Cut each line after |||" }, + { "command": "replaceLinesHelper.expandSql", "title": "Expand Sql" }, + { "command": "replaceLinesHelper.listToListFamily", "title": "List to list family (Kristy, Mike ...)" }, + { "command": "replaceLinesHelper.listToListWrappedComma", "title": "List to list wrapped comma" }, + { "command": "replaceLinesHelper.prettySql", "title": "Pretty Sql" }, + { "command": "replaceLinesHelper.removeComment", "title": "Remove comment" }, + { "command": "replaceLinesHelper.sortLength", "title": "Sort by Length" }, + { "command": "replaceLinesHelper.sortNormal", "title": "My Sort lines (ascending, case sensitive)" }, + { "command": "replaceLinesHelper.unwrapSql", "title": "Un-wrap Sql" }, + { "command": "replaceLinesHelper.wrapSqlCSharp", "title": "Wrap Sql for C#" }, + { "command": "replaceLinesHelper.wrapSqlVB", "title": "Wrap Sql for VB" } ], "keybindings": [ { - "command": "helper.unwrapSql", + "command": "replaceLinesHelper.unwrapSql", "key": "shift + f9", "when": "editorTextFocus" } @@ -57,9 +57,9 @@ "menus": { "editor/context": [ { - "command": "helper.unwrapSql", + "command": "replaceLinesHelper.unwrapSql", "when": "editorTextFocus", - "group": "helper@1" + "group": "replaceLinesHelper@1" } ] } diff --git a/type-script-helper/src/extension.ts b/type-script-helper/src/extension.ts index 011d79c..7993378 100644 --- a/type-script-helper/src/extension.ts +++ b/type-script-helper/src/extension.ts @@ -1,7 +1,8 @@ // The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below import * as vscode from 'vscode'; -import * as helper from './helper'; +import * as replaceLinesHelper from './replaceLinesHelper'; +import * as readOnlyLinesHelper from './readOnlyLinesHelper'; // this method is called when your extension is activated // your extension is activated the very first time the command is executed @@ -25,21 +26,21 @@ export function activate(context: vscode.ExtensionContext) { // context.subscriptions.push(disposable); const commands = [ - vscode.commands.registerCommand('helper.addCSharpComment', helper.addCSharpComment), - vscode.commands.registerCommand('helper.addVBComment', helper.addVBComment), - vscode.commands.registerCommand('helper.convertToRegularExpression', helper.convertToRegularExpression), - vscode.commands.registerCommand('helper.cutEachLine', helper.cutEachLine), - vscode.commands.registerCommand('helper.expandSql', helper.expandSql), - vscode.commands.registerCommand('helper.listToListFamily', helper.listToListFamily), - vscode.commands.registerCommand('helper.listToListWrappedComma', helper.listToListWrappedComma), - vscode.commands.registerCommand('helper.prettySql', helper.prettySql), - vscode.commands.registerCommand('helper.removeComment', helper.removeComment), - vscode.commands.registerCommand('helper.searchGoogle', helper.searchGoogle), - vscode.commands.registerCommand('helper.sortLength', helper.sortLength), - vscode.commands.registerCommand('helper.sortNormal', helper.sortNormal), - vscode.commands.registerCommand('helper.unwrapSql', helper.unwrapSql), - vscode.commands.registerCommand('helper.wrapSqlCSharp', helper.wrapSqlCSharp), - vscode.commands.registerCommand('helper.wrapSqlVB', helper.wrapSqlVB) + vscode.commands.registerCommand('readOnlyLinesHelper.searchGoogle', readOnlyLinesHelper.searchGoogle), + vscode.commands.registerCommand('replaceLinesHelper.addCSharpComment', replaceLinesHelper.addCSharpComment), + 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.expandSql', replaceLinesHelper.expandSql), + vscode.commands.registerCommand('replaceLinesHelper.listToListFamily', replaceLinesHelper.listToListFamily), + vscode.commands.registerCommand('replaceLinesHelper.listToListWrappedComma', replaceLinesHelper.listToListWrappedComma), + vscode.commands.registerCommand('replaceLinesHelper.prettySql', replaceLinesHelper.prettySql), + vscode.commands.registerCommand('replaceLinesHelper.removeComment', replaceLinesHelper.removeComment), + vscode.commands.registerCommand('replaceLinesHelper.sortLength', replaceLinesHelper.sortLength), + vscode.commands.registerCommand('replaceLinesHelper.sortNormal', replaceLinesHelper.sortNormal), + vscode.commands.registerCommand('replaceLinesHelper.unwrapSql', replaceLinesHelper.unwrapSql), + vscode.commands.registerCommand('replaceLinesHelper.wrapSqlCSharp', replaceLinesHelper.wrapSqlCSharp), + vscode.commands.registerCommand('replaceLinesHelper.wrapSqlVB', replaceLinesHelper.wrapSqlVB) ]; commands.forEach(command => context.subscriptions.push(command)); diff --git a/type-script-helper/src/readOnlyLinesHelper.ts b/type-script-helper/src/readOnlyLinesHelper.ts new file mode 100644 index 0000000..d616fc1 --- /dev/null +++ b/type-script-helper/src/readOnlyLinesHelper.ts @@ -0,0 +1,51 @@ +import * as vscode from 'vscode'; + +enum LinesAction { + searchGoogle +} + +function searchGoogleLogic(text: string, lines: string[]): void { + if (text.length > 0) { + vscode.env.openExternal( + vscode.Uri.parse(`https://www.google.com/search?q=${text.trim()}`) + ) + } + else if (lines.length > 0) { + vscode.env.openExternal( + vscode.Uri.parse(`https://www.google.com/search?q=${lines[0].trim()}`) + ) + } +} + +function getLines(textEditor: vscode.TextEditor, startLine: number, endLine: number) { + let results: string[] = []; + for (let i = startLine; i <= endLine; i++) { + results.push(textEditor.document.lineAt(i).text); + } + return results; +} + +function linesFunction(linesAction: LinesAction): Thenable | undefined { + const textEditor = vscode.window.activeTextEditor; + if (!textEditor) { + return undefined; + } + let text = ''; + var startLine = 0; + var endLine = textEditor.document.lineCount - 1; + const selection = textEditor.selection; + if (!selection.isEmpty) { + startLine = selection.start.line; + endLine = selection.end.line; + let range = new vscode.Range(selection.start, selection.end) + text = textEditor.document.getText(range); + } + let lines: string[] = getLines(textEditor, startLine, endLine); + switch (linesAction) { + case LinesAction.searchGoogle: { searchGoogleLogic(text, lines); break; } + default: { throw new Error(); } + } + return undefined; +} + +export const searchGoogle = () => linesFunction(LinesAction.searchGoogle); \ No newline at end of file diff --git a/type-script-helper/src/helper.ts b/type-script-helper/src/replaceLinesHelper.ts similarity index 96% rename from type-script-helper/src/helper.ts rename to type-script-helper/src/replaceLinesHelper.ts index 91a8e14..c38291f 100644 --- a/type-script-helper/src/helper.ts +++ b/type-script-helper/src/replaceLinesHelper.ts @@ -1,5 +1,4 @@ import * as vscode from 'vscode'; -import { stringify } from 'querystring'; type ArrayTransformer = (lines: string[]) => string[]; type SortingAlgorithm = (a: string, b: string) => number; @@ -15,7 +14,6 @@ enum LinesAction { prettySql, pdsfToFixedWidth, removeComment, - searchGoogle, sortLength, sortNormal, unwrapSql, @@ -158,14 +156,6 @@ function removeCommentLogic(lines: string[]): void { } } -function searchGoogleLogic(lines: string[]): void { - for (let i = 0; i < lines.length; ++i) { - vscode.env.openExternal( - vscode.Uri.parse(`https://www.google.com/search?q=${lines[i]}`) - ) - } -} - function makeSorter(algorithm?: SortingAlgorithm): ArrayTransformer { return function (lines: string[]): string[] { return lines.sort(algorithm); @@ -276,7 +266,6 @@ function linesFunction(linesAction: LinesAction): Thenable | undefined case LinesAction.listToListWrappedComma: { listToListWrappedCommaLogic(lines); break; } case LinesAction.prettySql: { prettySqlLogic(lines); break; } case LinesAction.removeComment: { removeCommentLogic(lines); break; } - case LinesAction.searchGoogle: { searchGoogleLogic(lines); break; } case LinesAction.sortLength: { sortLengthLogic(lines); break; } case LinesAction.sortNormal: { sortNormalLogic(lines); break; } case LinesAction.unwrapSql: { unwrapSqlLogic(lines); break; } @@ -297,7 +286,6 @@ export const listToListWrappedComma = () => linesFunction(LinesAction.listToList export const prettySql = () => linesFunction(LinesAction.prettySql); export const pdsfToFixedWidth = () => linesFunction(LinesAction.pdsfToFixedWidth); export const removeComment = () => linesFunction(LinesAction.removeComment); -export const searchGoogle = () => linesFunction(LinesAction.searchGoogle); export const sortLength = () => linesFunction(LinesAction.sortLength); export const sortNormal = () => linesFunction(LinesAction.sortNormal); export const unwrapSql = () => linesFunction(LinesAction.unwrapSql);