提交 745ac177 编写于 作者: I isidor

edit breakpoint in context menu

fixes #39714
上级 fd1c9a12
......@@ -7,8 +7,8 @@ import * as nls from 'vs/nls';
import * as resources from 'vs/base/common/resources';
import * as dom from 'vs/base/browser/dom';
import { onUnexpectedError } from 'vs/base/common/errors';
import { IAction } from 'vs/base/common/actions';
import { IDebugService, IBreakpoint, CONTEXT_BREAKPOINTS_FOCUSED, State, DEBUG_SCHEME, IFunctionBreakpoint, IExceptionBreakpoint, IEnablement } from 'vs/workbench/parts/debug/common/debug';
import { IAction, Action } from 'vs/base/common/actions';
import { IDebugService, IBreakpoint, CONTEXT_BREAKPOINTS_FOCUSED, EDITOR_CONTRIBUTION_ID, State, DEBUG_SCHEME, IFunctionBreakpoint, IExceptionBreakpoint, IEnablement, IDebugEditorContribution } from 'vs/workbench/parts/debug/common/debug';
import { ExceptionBreakpoint, FunctionBreakpoint, Breakpoint } from 'vs/workbench/parts/debug/common/debugModel';
import { AddFunctionBreakpointAction, ToggleBreakpointsActivatedAction, RemoveAllBreakpointsAction, RemoveBreakpointAction, EnableAllBreakpointsAction, DisableAllBreakpointsAction, ReapplyBreakpointsAction } from 'vs/workbench/parts/debug/browser/debugActions';
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
......@@ -24,7 +24,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { TPromise } from 'vs/base/common/winjs.base';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { IDelegate, IListContextMenuEvent, IRenderer } from 'vs/base/browser/ui/list/list';
import { IEditorService } from 'vs/platform/editor/common/editor';
import { IEditorService, IEditor } from 'vs/platform/editor/common/editor';
import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox';
import { IKeyboardEvent, StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes';
......@@ -32,6 +32,7 @@ import { WorkbenchList, IListService } from 'vs/platform/list/browser/listServic
import { ViewsViewletPanel, IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { attachInputBoxStyler } from 'vs/platform/theme/common/styler';
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
const $ = dom.$;
......@@ -80,11 +81,11 @@ export class BreakpointsView extends ViewsViewletPanel {
this.list.onContextMenu(this.onListContextMenu, this, this.disposables);
const handleBreakpointFocus = (preserveFocuse: boolean, selectFunctionBreakpoint: boolean) => {
const handleBreakpointFocus = (preserveFocuse: boolean, sideBySide: boolean, selectFunctionBreakpoint: boolean) => {
const focused = this.list.getFocusedElements();
const element = focused.length ? focused[0] : undefined;
if (element instanceof Breakpoint) {
openBreakpointSource(element, event, preserveFocuse, this.debugService, this.editorService);
openBreakpointSource(element, sideBySide, preserveFocuse, this.debugService, this.editorService).done(undefined, onUnexpectedError);
}
if (selectFunctionBreakpoint && element instanceof FunctionBreakpoint) {
this.debugService.getViewModel().setSelectedFunctionBreakpoint(element);
......@@ -94,14 +95,14 @@ export class BreakpointsView extends ViewsViewletPanel {
this.disposables.push(this.list.onKeyUp(e => {
const event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.Enter)) {
handleBreakpointFocus(false, false);
handleBreakpointFocus(false, event && (event.ctrlKey || event.metaKey), false);
}
}));
this.disposables.push(this.list.onMouseDblClick(e => {
handleBreakpointFocus(false, true);
handleBreakpointFocus(false, false, true);
}));
this.disposables.push(this.list.onMouseClick(e => {
handleBreakpointFocus(true, false);
handleBreakpointFocus(true, false, false);
}));
this.list.splice(0, this.list.length, this.elements);
......@@ -115,7 +116,23 @@ export class BreakpointsView extends ViewsViewletPanel {
private onListContextMenu(e: IListContextMenuEvent<IEnablement>): void {
const actions: IAction[] = [];
const element = e.element;
if (element instanceof Breakpoint) {
actions.push(new Action('workbench.action.debug.openEditorAndEditBreakpoint', nls.localize('editConditionalBreakpoint', "Edit Breakpoint..."), undefined, true, () => {
return openBreakpointSource(element, false, false, this.debugService, this.editorService).then(editor => {
const codeEditor = editor.getControl();
if (isCodeEditor(codeEditor)) {
codeEditor.getContribution<IDebugEditorContribution>(EDITOR_CONTRIBUTION_ID).showBreakpointWidget(element.lineNumber, element.column);
}
});
}));
actions.push(new Separator());
}
actions.push(new RemoveBreakpointAction(RemoveBreakpointAction.ID, RemoveBreakpointAction.LABEL, this.debugService, this.keybindingService));
if (this.debugService.getModel().getBreakpoints().length + this.debugService.getModel().getFunctionBreakpoints().length > 1) {
actions.push(new RemoveAllBreakpointsAction(RemoveAllBreakpointsAction.ID, RemoveAllBreakpointsAction.LABEL, this.debugService, this.keybindingService));
actions.push(new Separator());
......@@ -130,7 +147,7 @@ export class BreakpointsView extends ViewsViewletPanel {
this.contextMenuService.showContextMenu({
getAnchor: () => e.anchor,
getActions: () => TPromise.as(actions),
getActionsContext: () => e.element
getActionsContext: () => element
});
}
......@@ -471,12 +488,11 @@ class FunctionBreakpointInputRenderer implements IRenderer<IFunctionBreakpoint,
}
}
function openBreakpointSource(breakpoint: Breakpoint, event: any, preserveFocus: boolean, debugService: IDebugService, editorService: IEditorService): void {
function openBreakpointSource(breakpoint: Breakpoint, sideBySide: boolean, preserveFocus: boolean, debugService: IDebugService, editorService: IEditorService): TPromise<IEditor> {
if (breakpoint.uri.scheme === DEBUG_SCHEME && debugService.state === State.Inactive) {
return;
return TPromise.as(null);
}
const sideBySide = (event && (event.ctrlKey || event.metaKey));
const selection = breakpoint.endLineNumber ? {
startLineNumber: breakpoint.lineNumber,
endLineNumber: breakpoint.endLineNumber,
......@@ -489,7 +505,7 @@ function openBreakpointSource(breakpoint: Breakpoint, event: any, preserveFocus:
endColumn: breakpoint.column || Constants.MAX_SAFE_SMALL_INTEGER
};
editorService.openEditor({
return editorService.openEditor({
resource: breakpoint.uri,
options: {
preserveFocus,
......@@ -498,5 +514,5 @@ function openBreakpointSource(breakpoint: Breakpoint, event: any, preserveFocus:
revealInCenterIfOutsideViewport: true,
pinned: !preserveFocus
}
}, sideBySide).done(undefined, onUnexpectedError);
}, sideBySide);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册