mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-23 11:54:25 +00:00
Centralize the check for languageId on document
Also move visibleRustEditors to Ctx
This commit is contained in:
parent
b95756d21b
commit
2f54c1d653
5 changed files with 25 additions and 24 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue