Skip to content

Commit

Permalink
Update 'run selected text' isVisible and isEnabled handling
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
vince-fugnitto committed Aug 26, 2019
1 parent e4390f4 commit 530eb75
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/task/src/browser/task-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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()
}
);
Expand Down

0 comments on commit 530eb75

Please sign in to comment.