Cut each line after |||
This commit is contained in:
@ -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);
|
Reference in New Issue
Block a user