mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-24 09:05:34 +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,14 +1,14 @@
|
|||
import { TextEditor } from "vscode";
|
||||
import { TextDocumentIdentifier } from "vscode-languageclient";
|
||||
import { TextEditor } from 'vscode';
|
||||
import { TextDocumentIdentifier } from 'vscode-languageclient';
|
||||
|
||||
import { Server } from "../server";
|
||||
import { Decoration } from "../highlighting";
|
||||
import { Decoration } from '../highlighting';
|
||||
import { Server } from '../server';
|
||||
|
||||
export async function handle(editor: TextEditor | undefined) {
|
||||
if (!Server.config.highlightingOn || !editor || editor.document.languageId != 'rust') return
|
||||
let params: TextDocumentIdentifier = {
|
||||
uri: editor.document.uri.toString()
|
||||
}
|
||||
let decorations = await Server.client.sendRequest<Decoration[]>("m/decorationsRequest", params)
|
||||
Server.highlighter.setHighlights(editor, decorations)
|
||||
}
|
||||
if (!Server.config.highlightingOn || !editor || editor.document.languageId != 'rust') { return; }
|
||||
const params: TextDocumentIdentifier = {
|
||||
uri: editor.document.uri.toString(),
|
||||
};
|
||||
const decorations = await Server.client.sendRequest<Decoration[]>('m/decorationsRequest', params);
|
||||
Server.highlighter.setHighlights(editor, decorations);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,16 +4,16 @@ import { syntaxTreeUri, TextDocumentContentProvider } from '../commands/syntaxTr
|
|||
|
||||
export function createHandler(textDocumentContentProvider: TextDocumentContentProvider) {
|
||||
return (event: vscode.TextDocumentChangeEvent) => {
|
||||
let doc = event.document
|
||||
if (doc.languageId != "rust") return
|
||||
const doc = event.document;
|
||||
if (doc.languageId != 'rust') { return; }
|
||||
afterLs(() => {
|
||||
textDocumentContentProvider.eventEmitter.fire(syntaxTreeUri);
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// We need to order this after LS updates, but there's no API for that.
|
||||
// Hence, good old setTimeout.
|
||||
function afterLs(f: () => any) {
|
||||
setTimeout(f, 10)
|
||||
setTimeout(f, 10);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue