Centralize the check for languageId on document

Also move visibleRustEditors to Ctx
This commit is contained in:
Julien Roncaglia 2020-03-02 22:54:29 +01:00
parent b95756d21b
commit 2f54c1d653
5 changed files with 25 additions and 24 deletions

View file

@ -1,6 +1,7 @@
import * as lc from "vscode-languageclient";
import * as vscode from "vscode";
import { strict as nativeAssert } from "assert";
import { TextDocument } from "vscode";
export function assert(condition: boolean, explanation: string): asserts condition {
try {
@ -65,3 +66,10 @@ export async function sendRequestWithRetry<TParam, TRet>(
function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export function isRustDocument(document: TextDocument) {
return document.languageId === 'rust'
// SCM diff views have the same URI as the on-disk document but not the same content
&& document.uri.scheme !== 'git'
&& document.uri.scheme !== 'svn';
}