From a63446f2549afbeafe632c425112b7c38b5c9991 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 7 Mar 2020 14:07:44 +0200 Subject: vscode: prerefactor util.ts and ctx.ts --- editors/code/src/ctx.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'editors/code/src/ctx.ts') diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index b4e983a0c..25ef38aed 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -3,7 +3,7 @@ import * as lc from 'vscode-languageclient'; import { Config } from './config'; import { createClient } from './client'; -import { isRustDocument } from './util'; +import { isRustEditor, RustEditor } from './util'; export class Ctx { private constructor( @@ -22,17 +22,15 @@ export class Ctx { return res; } - get activeRustEditor(): vscode.TextEditor | undefined { + get activeRustEditor(): RustEditor | undefined { const editor = vscode.window.activeTextEditor; - return editor && isRustDocument(editor.document) + return editor && isRustEditor(editor) ? editor : undefined; } - get visibleRustEditors(): vscode.TextEditor[] { - return vscode.window.visibleTextEditors.filter( - editor => isRustDocument(editor.document), - ); + get visibleRustEditors(): RustEditor[] { + return vscode.window.visibleTextEditors.filter(isRustEditor); } registerCommand(name: string, factory: (ctx: Ctx) => Cmd) { -- cgit v1.2.3