From 2fb854ccdae6f1f12b60441e5c3b283bdc81fb0a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Aug 2018 18:28:30 +0300 Subject: :tada: extend selection --- code/src/main.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'code/src') diff --git a/code/src/main.ts b/code/src/main.ts index 75a824b7b..72bef7061 100644 --- a/code/src/main.ts +++ b/code/src/main.ts @@ -34,6 +34,16 @@ export function activate(context: vscode.ExtensionContext) { )) registerCommand('libsyntax-rust.syntaxTree', () => openDoc(uris.syntaxTree)) + registerCommand('libsyntax-rust.extendSelection', () => { + let editor = vscode.window.activeTextEditor + let file = activeSyntax() + if (editor == null || file == null) return + editor.selections = editor.selections.map((s) => { + let range = file.extendSelection(s) + if (range == null) return null + return new vscode.Selection(range.start, range.end) + }) + }) } export function deactivate() { } @@ -49,6 +59,11 @@ export class Syntax { syntaxTree(): string { return this.imp.syntaxTree() } highlight(): Array<[number, number, string]> { return this.imp.highlight() } + extendSelection(range: vscode.Range): vscode.Range { + let range_ = fromVsRange(this.doc, range); + let extRange = this.imp.extendSelection(range_[0], range_[1]); + return toVsRange(this.doc, extRange); + } } -- cgit v1.2.3