Cut each line after |||
This commit is contained in:
parent
91cb50b187
commit
63fe43adf0
BIN
type-script-helper-1.2.3.vsix
Normal file
BIN
type-script-helper-1.2.3.vsix
Normal file
Binary file not shown.
@ -22,7 +22,7 @@ None
|
||||
|
||||
L:
|
||||
|
||||
cd "L:\GitHub\YO-VSCode"
|
||||
cd "L:\GitHub\YO-VSCode\type-script-helper"
|
||||
|
||||
yo code
|
||||
|
||||
@ -34,7 +34,7 @@ Modify .package
|
||||
|
||||
Add publisher
|
||||
|
||||
cd type-script-helper
|
||||
cd "L:\GitHub\YO-VSCode\type-script-helper"
|
||||
|
||||
vsce package
|
||||
|
||||
|
@ -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.2",
|
||||
"version": "1.2.3",
|
||||
"engines": {
|
||||
"vscode": "^1.40.0"
|
||||
},
|
||||
@ -25,7 +25,8 @@
|
||||
"onCommand:helper.unwrapSql",
|
||||
"onCommand:helper.wrapSqlCSharp",
|
||||
"onCommand:helper.wrapSqlVB",
|
||||
"onCommand:helper.sortLength"
|
||||
"onCommand:helper.sortLength",
|
||||
"onCommand:helper.cutEachLine"
|
||||
],
|
||||
"contributes": {
|
||||
"commands": [
|
||||
@ -41,7 +42,8 @@
|
||||
{ "command": "helper.unwrapSql", "title": "Un-wrap Sql" },
|
||||
{ "command": "helper.wrapSqlCSharp", "title": "Wrap Sql for C#" },
|
||||
{ "command": "helper.wrapSqlVB", "title": "Wrap Sql for VB" },
|
||||
{ "command": "helper.sortLength", "title": "Sort by Length" }
|
||||
{ "command": "helper.sortLength", "title": "Sort by Length" },
|
||||
{ "command": "helper.cutEachLine", "title": "Cut each line after |||" }
|
||||
],
|
||||
"keybindings": [
|
||||
{
|
||||
|
@ -37,7 +37,8 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
vscode.commands.registerCommand('helper.unwrapSql', helper.unwrapSql),
|
||||
vscode.commands.registerCommand('helper.wrapSqlCSharp', helper.wrapSqlCSharp),
|
||||
vscode.commands.registerCommand('helper.wrapSqlVB', helper.wrapSqlVB),
|
||||
vscode.commands.registerCommand('helper.sortLength', helper.sortLength)
|
||||
vscode.commands.registerCommand('helper.sortLength', helper.sortLength),
|
||||
vscode.commands.registerCommand('helper.cutEachLine', helper.cutEachLine)
|
||||
];
|
||||
|
||||
commands.forEach(command => context.subscriptions.push(command));
|
||||
|
@ -17,7 +17,8 @@ enum LinesAction {
|
||||
unwrapSql,
|
||||
wrapSqlCSharp,
|
||||
wrapSqlVB,
|
||||
sortLength
|
||||
sortLength,
|
||||
cutEachLine
|
||||
}
|
||||
|
||||
function removeBlanks(lines: string[]): void {
|
||||
@ -223,6 +224,16 @@ function sortLengthLogic(lines: string[]): void {
|
||||
removeBlanks(lines);
|
||||
}
|
||||
|
||||
function cutEachLineLogic(lines: string[]): void {
|
||||
for (let i = 0; i < lines.length; ++i) {
|
||||
if(lines[i].length > 0 && lines[i].indexOf("|||") > 0) {
|
||||
lines[i] = lines[i].substr(0, lines[i].indexOf("|||"));
|
||||
}
|
||||
lines[i] = lines[i].trim();
|
||||
}
|
||||
removeBlanks(lines);
|
||||
}
|
||||
|
||||
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);
|
||||
@ -257,6 +268,7 @@ function linesFunction(linesAction: LinesAction): Thenable<boolean> | undefined
|
||||
case LinesAction.wrapSqlCSharp: { wrapSqlCSharpLogic(lines); break; }
|
||||
case LinesAction.wrapSqlVB: { wrapSqlVBLogic(lines); break; }
|
||||
case LinesAction.sortLength: { sortLengthLogic(lines); break; }
|
||||
case LinesAction.cutEachLine: { cutEachLineLogic(lines); break; }
|
||||
default: { throw new Error(); }
|
||||
}
|
||||
return returnLines(textEditor, startLine, endLine, lines);
|
||||
@ -274,4 +286,5 @@ export const sortNormal = () => linesFunction(LinesAction.sortNormal);
|
||||
export const unwrapSql = () => linesFunction(LinesAction.unwrapSql);
|
||||
export const wrapSqlCSharp = () => linesFunction(LinesAction.wrapSqlCSharp);
|
||||
export const wrapSqlVB = () => linesFunction(LinesAction.wrapSqlVB);
|
||||
export const sortLength = () => linesFunction(LinesAction.sortLength);
|
||||
export const sortLength = () => linesFunction(LinesAction.sortLength);
|
||||
export const cutEachLine = () => linesFunction(LinesAction.cutEachLine);
|
Loading…
x
Reference in New Issue
Block a user