diff options
Diffstat (limited to 'editors/code/src/ctx.ts')
-rw-r--r-- | editors/code/src/ctx.ts | 9 |
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 | ||
4 | import { Config } from './config'; | 4 | import { Config } from './config'; |
5 | import { createClient } from './client'; | 5 | import { createClient } from './client'; |
6 | import { isRustDocument } from './util'; | ||
6 | 7 | ||
7 | export class Ctx { | 8 | export 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); |