matching brace

This commit is contained in:
Aleksey Kladov 2018-08-16 00:23:22 +03:00
parent aa0d344581
commit c631b585a7
9 changed files with 135 additions and 14 deletions

View file

@ -35,6 +35,22 @@ export function activate(context: vscode.ExtensionContext) {
return new vscode.Selection(r.start, r.end)
})
})
registerCommand('libsyntax-rust.matchingBrace', async () => {
let editor = vscode.window.activeTextEditor
if (editor == null || editor.document.languageId != "rust") return
let request: FindMatchingBraceParams = {
textDocument: { uri: editor.document.uri.toString() },
offsets: editor.selections.map((s) => {
return client.code2ProtocolConverter.asPosition(s.active)
})
}
let response = await client.sendRequest<lc.Position[]>("m/findMatchingBrace", request)
editor.selections = editor.selections.map((sel, idx) => {
let active = client.protocol2CodeConverter.asPosition(response[idx])
let anchor = sel.isEmpty ? active : sel.anchor
return new vscode.Selection(anchor, active)
})
})
dispose(vscode.workspace.registerTextDocumentContentProvider(
'libsyntax-rust',
@ -184,6 +200,11 @@ interface ExtendSelectionResult {
selections: lc.Range[];
}
interface FindMatchingBraceParams {
textDocument: lc.TextDocumentIdentifier;
offsets: lc.Position[];
}
interface PublishDecorationsParams {
uri: string,
decorations: Decoration[],