From be6dfc0b2408cc98ff5ebcc0e6d576f6571084ae Mon Sep 17 00:00:00 2001 From: Vincent Fugnitto Date: Thu, 22 Aug 2019 09:32:22 -0400 Subject: [PATCH] Update 'run selected text' isVisible and isEnabled handling Fixes #6017 - previously the command `Task: Run Selected Text` was always enabled and visible which lead to a poor user experience when no editor was currently opened. The handling for `isVisible` and `isEnabled` was updated to determine if an editor is currently opened using the `EditorManager`. Signed-off-by: Vincent Fugnitto --- packages/task/src/browser/task-frontend-contribution.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/task/src/browser/task-frontend-contribution.ts b/packages/task/src/browser/task-frontend-contribution.ts index aac2c3769fef5..12a6add725670 100644 --- a/packages/task/src/browser/task-frontend-contribution.ts +++ b/packages/task/src/browser/task-frontend-contribution.ts @@ -28,6 +28,7 @@ import { TaskService } from './task-service'; import { TerminalMenus } from '@theia/terminal/lib/browser/terminal-frontend-contribution'; import { TaskSchemaUpdater } from './task-schema-updater'; import { TaskConfiguration, TaskWatcher } from '../common'; +import { EditorManager } from '@theia/editor/lib/browser'; export namespace TaskCommands { const TASK_CATEGORY = 'Task'; @@ -92,6 +93,9 @@ export class TaskFrontendContribution implements CommandContribution, MenuContri @inject(QuickOpenTask) protected readonly quickOpenTask: QuickOpenTask; + @inject(EditorManager) + protected readonly editorManager: EditorManager; + @inject(FrontendApplication) protected readonly app: FrontendApplication; @@ -222,7 +226,8 @@ export class TaskFrontendContribution implements CommandContribution, MenuContri registry.registerCommand( TaskCommands.TASK_RUN_TEXT, { - isEnabled: () => true, + isVisible: () => !!this.editorManager.currentEditor, + isEnabled: () => !!this.editorManager.currentEditor, execute: () => this.taskService.runSelectedText() } );