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

@ -4,7 +4,7 @@ import * as ra from './rust-analyzer-api';
import { ColorTheme, TextMateRuleSettings } from './color_theme';
import { Ctx } from './ctx';
import { sendRequestWithRetry } from './util';
import { sendRequestWithRetry, isRustDocument } from './util';
export function activateHighlighting(ctx: Ctx) {
const highlighter = new Highlighter(ctx);
@ -36,7 +36,7 @@ export function activateHighlighting(ctx: Ctx) {
vscode.window.onDidChangeActiveTextEditor(
async (editor: vscode.TextEditor | undefined) => {
if (!editor || editor.document.languageId !== 'rust') return;
if (!editor || !isRustDocument(editor.document)) return;
if (!ctx.config.highlightingOn) return;
const client = ctx.client;
if (!client) return;