提交 09e94a70 编写于 作者: R Ramya Achutha Rao

Multi cursor for Wrap with Abbreviation command #27621

上级 24d52d63
......@@ -18,17 +18,19 @@ export function wrapWithAbbreviation() {
vscode.window.showInformationMessage('No editor is active');
return;
}
let rangeToReplace: vscode.Range = editor.selection;
if (rangeToReplace.isEmpty) {
rangeToReplace = new vscode.Range(rangeToReplace.start.line, 0, rangeToReplace.start.line, editor.document.lineAt(rangeToReplace.start.line).text.length);
}
let textToReplace = editor.document.getText(rangeToReplace);
let syntax = getSyntax(editor.document);
vscode.window.showInputBox({ prompt: 'Enter Abbreviation' }).then(abbr => {
if (!abbr || !abbr.trim()) { return; }
let expandedText = expand(abbr, getExpandOptions(syntax, textToReplace));
editor.insertSnippet(new vscode.SnippetString(expandedText), rangeToReplace);
editor.selections.forEach(selection => {
let rangeToReplace: vscode.Range = selection;
if (rangeToReplace.isEmpty) {
rangeToReplace = new vscode.Range(rangeToReplace.start.line, 0, rangeToReplace.start.line, editor.document.lineAt(rangeToReplace.start.line).text.length);
}
let textToReplace = editor.document.getText(rangeToReplace);
let expandedText = expand(abbr, getExpandOptions(syntax, textToReplace));
editor.insertSnippet(new vscode.SnippetString(expandedText), rangeToReplace);
});
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册