mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Apply tslint suggestions, round one
This commit is contained in:
parent
69de7e2fd7
commit
4d62cfccbb
16 changed files with 257 additions and 241 deletions
|
@ -1,6 +1,6 @@
|
|||
import * as vscode from 'vscode';
|
||||
|
||||
import { TextDocumentIdentifier, Position } from "vscode-languageclient";
|
||||
import { Position, TextDocumentIdentifier } from 'vscode-languageclient';
|
||||
import { Server } from '../server';
|
||||
|
||||
interface FindMatchingBraceParams {
|
||||
|
@ -9,19 +9,19 @@ interface FindMatchingBraceParams {
|
|||
}
|
||||
|
||||
export async function handle() {
|
||||
let editor = vscode.window.activeTextEditor
|
||||
if (editor == null || editor.document.languageId != "rust") return
|
||||
let request: FindMatchingBraceParams = {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (editor == null || editor.document.languageId != 'rust') { return; }
|
||||
const request: FindMatchingBraceParams = {
|
||||
textDocument: { uri: editor.document.uri.toString() },
|
||||
offsets: editor.selections.map((s) => {
|
||||
return Server.client.code2ProtocolConverter.asPosition(s.active)
|
||||
})
|
||||
}
|
||||
let response = await Server.client.sendRequest<Position[]>("m/findMatchingBrace", request)
|
||||
return Server.client.code2ProtocolConverter.asPosition(s.active);
|
||||
}),
|
||||
};
|
||||
const response = await Server.client.sendRequest<Position[]>('m/findMatchingBrace', request);
|
||||
editor.selections = editor.selections.map((sel, idx) => {
|
||||
let active = Server.client.protocol2CodeConverter.asPosition(response[idx])
|
||||
let anchor = sel.isEmpty ? active : sel.anchor
|
||||
return new vscode.Selection(anchor, active)
|
||||
})
|
||||
editor.revealRange(editor.selection)
|
||||
};
|
||||
const active = Server.client.protocol2CodeConverter.asPosition(response[idx]);
|
||||
const anchor = sel.isEmpty ? active : sel.anchor;
|
||||
return new vscode.Selection(anchor, active);
|
||||
});
|
||||
editor.revealRange(editor.selection);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue