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

@ -2,6 +2,7 @@ import * as vscode from 'vscode';
import * as ra from '../rust-analyzer-api';
import { Ctx, Cmd } from '../ctx';
import { isRustDocument } from '../util';
// Opens the virtual file that will show the syntax tree
//
@ -19,7 +20,7 @@ export function syntaxTree(ctx: Ctx): Cmd {
vscode.workspace.onDidChangeTextDocument(
(event: vscode.TextDocumentChangeEvent) => {
const doc = event.document;
if (doc.languageId !== 'rust') return;
if (!isRustDocument(doc)) return;
afterLs(() => tdcp.eventEmitter.fire(tdcp.uri));
},
null,
@ -28,7 +29,7 @@ export function syntaxTree(ctx: Ctx): Cmd {
vscode.window.onDidChangeActiveTextEditor(
(editor: vscode.TextEditor | undefined) => {
if (!editor || editor.document.languageId !== 'rust') return;
if (!editor || !isRustDocument(editor.document)) return;
tdcp.eventEmitter.fire(tdcp.uri);
},
null,