Skip to content

Commit

Permalink
debug: bring back selectionToWatch action
Browse files Browse the repository at this point in the history
fixes #10192
  • Loading branch information
isidorn committed Aug 24, 2016
1 parent 85c02e9 commit 2186992
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
37 changes: 32 additions & 5 deletions src/vs/workbench/parts/debug/browser/debugActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ import nls = require('vs/nls');
import {Action} from 'vs/base/common/actions';
import lifecycle = require('vs/base/common/lifecycle');
import {TPromise} from 'vs/base/common/winjs.base';
import {KeyMod, KeyCode} from 'vs/base/common/keyCodes';
import {Range} from 'vs/editor/common/core/range';
import editorCommon = require('vs/editor/common/editorCommon');
import editorbrowser = require('vs/editor/browser/editorBrowser');
import {ServicesAccessor, EditorAction} from 'vs/editor/common/editorCommonExtensions';
import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey';
import {ICommandService} from 'vs/platform/commands/common/commands';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import debug = require('vs/workbench/parts/debug/common/debug');
import model = require('vs/workbench/parts/debug/common/debugModel');
import {BreakpointWidget} from 'vs/workbench/parts/debug/browser/breakpointWidget';
import {IPartService} from 'vs/workbench/services/part/common/partService';
import {IPanelService} from 'vs/workbench/services/panel/common/panelService';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {ServicesAccessor, EditorAction} from 'vs/editor/common/editorCommonExtensions';
import {KeyMod, KeyCode} from 'vs/base/common/keyCodes';
import {IViewletService} from 'vs/workbench/services/viewlet/common/viewletService';
import IDebugService = debug.IDebugService;

import EditorContextKeys = editorCommon.EditorContextKeys;
Expand Down Expand Up @@ -613,7 +614,8 @@ export class RunToCursorAction extends EditorAction {
alias: 'Debug: Run to Cursor',
precondition: debug.CONTEXT_IN_DEBUG_MODE,
menuOpts: {
group: 'debug'
group: 'debug',
order: 2
}
});
}
Expand Down Expand Up @@ -672,7 +674,8 @@ export class SelectionToReplAction extends EditorAction {
alias: 'Debug: Evaluate',
precondition: ContextKeyExpr.and(EditorContextKeys.HasNonEmptySelection, debug.CONTEXT_IN_DEBUG_MODE),
menuOpts: {
group: 'debug'
group: 'debug',
order: 0
}
});
}
Expand All @@ -688,6 +691,30 @@ export class SelectionToReplAction extends EditorAction {
}
}

export class SelectionToWatchExpressionsAction extends EditorAction {

constructor() {
super({
id: 'editor.debug.action.selectionToWatch',
label: nls.localize('debugAddToWatch', "Debug: Add to Watch"),
alias: 'Debug: Add to Watch',
precondition: ContextKeyExpr.and(EditorContextKeys.HasNonEmptySelection, debug.CONTEXT_IN_DEBUG_MODE),
menuOpts: {
group: 'debug',
order: 1
}
});
}

public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): TPromise<void> {
const debugService = accessor.get(IDebugService);
const viewletService = accessor.get(IViewletService);

const text = editor.getModel().getValueInRange(editor.getSelection());
return viewletService.openViewlet(debug.VIEWLET_ID).then(() => debugService.addWatchExpression(text));
}
}

export class ShowDebugHoverAction extends EditorAction {

constructor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import wbext = require('vs/workbench/common/contributions');
import * as debug from 'vs/workbench/parts/debug/common/debug';
import {DebugEditorModelManager} from 'vs/workbench/parts/debug/browser/debugEditorModelManager';
import {ToggleBreakpointAction, EditorConditionalBreakpointAction, ShowDebugHoverAction, SelectionToReplAction, RunToCursorAction, StepOverAction, ClearReplAction, FocusReplAction,
StepIntoAction, StepOutAction, StartAction, StepBackAction, RestartAction, ContinueAction, StopAction, DisconnectAction, PauseAction, AddFunctionBreakpointAction,
StepIntoAction, StepOutAction, StartAction, StepBackAction, RestartAction, ContinueAction, StopAction, DisconnectAction, PauseAction, AddFunctionBreakpointAction, SelectionToWatchExpressionsAction,
ConfigureAction, ToggleReplAction, DisableAllBreakpointsAction, EnableAllBreakpointsAction, RemoveAllBreakpointsAction, RunAction, ReapplyBreakpointsAction} from 'vs/workbench/parts/debug/browser/debugActions';
import debugwidget = require('vs/workbench/parts/debug/browser/debugActionsWidget');
import service = require('vs/workbench/parts/debug/electron-browser/debugService');
Expand Down Expand Up @@ -55,6 +55,7 @@ CommonEditorRegistry.registerEditorAction(new ShowDebugHoverAction());
CommonEditorRegistry.registerEditorAction(new EditorConditionalBreakpointAction());
CommonEditorRegistry.registerEditorAction(new SelectionToReplAction());
CommonEditorRegistry.registerEditorAction(new RunToCursorAction());
CommonEditorRegistry.registerEditorAction(new SelectionToWatchExpressionsAction());

// register viewlet
(<viewlet.ViewletRegistry>platform.Registry.as(viewlet.Extensions.Viewlets)).registerViewlet(new viewlet.ViewletDescriptor(
Expand Down

0 comments on commit 2186992

Please sign in to comment.