aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/ctx.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/ctx.ts')
-rw-r--r--editors/code/src/ctx.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 43540e0d8..b4e983a0c 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -3,6 +3,7 @@ import * as lc from 'vscode-languageclient';
3 3
4import { Config } from './config'; 4import { Config } from './config';
5import { createClient } from './client'; 5import { createClient } from './client';
6import { isRustDocument } from './util';
6 7
7export class Ctx { 8export class Ctx {
8 private constructor( 9 private constructor(
@@ -23,11 +24,17 @@ export class Ctx {
23 24
24 get activeRustEditor(): vscode.TextEditor | undefined { 25 get activeRustEditor(): vscode.TextEditor | undefined {
25 const editor = vscode.window.activeTextEditor; 26 const editor = vscode.window.activeTextEditor;
26 return editor && editor.document.languageId === 'rust' 27 return editor && isRustDocument(editor.document)
27 ? editor 28 ? editor
28 : undefined; 29 : undefined;
29 } 30 }
30 31
32 get visibleRustEditors(): vscode.TextEditor[] {
33 return vscode.window.visibleTextEditors.filter(
34 editor => isRustDocument(editor.document),
35 );
36 }
37
31 registerCommand(name: string, factory: (ctx: Ctx) => Cmd) { 38 registerCommand(name: string, factory: (ctx: Ctx) => Cmd) {
32 const fullName = `rust-analyzer.${name}`; 39 const fullName = `rust-analyzer.${name}`;
33 const cmd = factory(this); 40 const cmd = factory(this);