diff --git a/src/vs/code/electron-main/menus.ts b/src/vs/code/electron-main/menus.ts index 2b9cc41a2e718..6b8b270026902 100644 --- a/src/vs/code/electron-main/menus.ts +++ b/src/vs/code/electron-main/menus.ts @@ -852,7 +852,7 @@ export class CodeMenu { const toggleBreakpoint = this.createMenuItem(nls.localize({ key: 'miToggleBreakpoint', comment: ['&& denotes a mnemonic'] }, "Toggle &&Breakpoint"), 'editor.debug.action.toggleBreakpoint'); const breakpointsMenu = new Menu(); breakpointsMenu.append(this.createMenuItem(nls.localize({ key: 'miConditionalBreakpoint', comment: ['&& denotes a mnemonic'] }, "&&Conditional Breakpoint..."), 'editor.debug.action.conditionalBreakpoint')); - breakpointsMenu.append(this.createMenuItem(nls.localize({ key: 'miColumnBreakpoint', comment: ['&& denotes a mnemonic'] }, "C&&olumn Breakpoint"), 'editor.debug.action.toggleColumnBreakpoint')); + breakpointsMenu.append(this.createMenuItem(nls.localize({ key: 'miInlineBreakpoint', comment: ['&& denotes a mnemonic'] }, "Inline Breakp&&oint"), 'editor.debug.action.toggleInlineBreakpoint')); breakpointsMenu.append(this.createMenuItem(nls.localize({ key: 'miFunctionBreakpoint', comment: ['&& denotes a mnemonic'] }, "&&Function Breakpoint..."), 'workbench.debug.viewlet.action.addFunctionBreakpointAction')); breakpointsMenu.append(this.createMenuItem(nls.localize({ key: 'miLogPoint', comment: ['&& denotes a mnemonic'] }, "&&Logpoint..."), 'editor.debug.action.toggleLogPoint')); const newBreakpoints = new MenuItem({ label: this.mnemonicLabel(nls.localize({ key: 'miNewBreakpoint', comment: ['&& denotes a mnemonic'] }, "&&New Breakpoint")), submenu: breakpointsMenu }); diff --git a/src/vs/workbench/parts/debug/browser/debugCommands.ts b/src/vs/workbench/parts/debug/browser/debugCommands.ts index 07242f1f51da6..e181f394f07fc 100644 --- a/src/vs/workbench/parts/debug/browser/debugCommands.ts +++ b/src/vs/workbench/parts/debug/browser/debugCommands.ts @@ -23,6 +23,7 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { openBreakpointSource } from 'vs/workbench/parts/debug/browser/breakpointsView'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { InputFocusedContext } from 'vs/platform/workbench/common/contextkeys'; +import { CommandsRegistry } from 'vs/platform/commands/common/commands'; export function registerCommands(): void { @@ -197,46 +198,51 @@ export function registerCommands(): void { } }); - const COLUMN_BREAKPOINT_COMMAND_ID = 'editor.debug.action.toggleColumnBreakpoint'; + const INLINE_BREAKPOINT_COMMAND_ID = 'editor.debug.action.toggleInlineBreakpoint'; + const inlineBreakpointHandler = (accessor) => { + const debugService = accessor.get(IDebugService); + const editorService = accessor.get(IWorkbenchEditorService); + const editor = editorService.getActiveEditor(); + const control = editor && editor.getControl(); + if (control) { + const position = control.getPosition(); + const modelUri = control.getModel().uri; + const bp = debugService.getModel().getBreakpoints({ lineNumber: position.lineNumber, uri: modelUri }) + .filter(bp => (bp.column === position.column || !bp.column && position.column <= 1)).pop(); + + if (bp) { + return TPromise.as(null); + } + if (debugService.getConfigurationManager().canSetBreakpointsIn(control.getModel())) { + return debugService.addBreakpoints(modelUri, [{ lineNumber: position.lineNumber, column: position.column > 1 ? position.column : undefined }]); + } + } + + return TPromise.as(null); + }; KeybindingsRegistry.registerCommandAndKeybindingRule({ weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), primary: KeyMod.Shift | KeyCode.F9, when: EditorContextKeys.editorTextFocus, - id: COLUMN_BREAKPOINT_COMMAND_ID, - handler: (accessor) => { - const debugService = accessor.get(IDebugService); - const editorService = accessor.get(IWorkbenchEditorService); - const editor = editorService.getActiveEditor(); - const control = editor && editor.getControl(); - if (control) { - const position = control.getPosition(); - const modelUri = control.getModel().uri; - const bp = debugService.getModel().getBreakpoints({ lineNumber: position.lineNumber, uri: modelUri }) - .filter(bp => (bp.column === position.column || !bp.column && position.column <= 1)).pop(); - - if (bp) { - return TPromise.as(null); - } - if (debugService.getConfigurationManager().canSetBreakpointsIn(control.getModel())) { - return debugService.addBreakpoints(modelUri, [{ lineNumber: position.lineNumber, column: position.column > 1 ? position.column : undefined }]); - } - } - - return TPromise.as(null); - } + id: INLINE_BREAKPOINT_COMMAND_ID, + handler: inlineBreakpointHandler + }); + CommandsRegistry.registerCommand({ + id: 'editor.debug.action.toggleColumnBreakpoint', + handler: inlineBreakpointHandler }); MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { - id: COLUMN_BREAKPOINT_COMMAND_ID, - title: nls.localize('columnBreakpoint', "Column Breakpoint"), + id: INLINE_BREAKPOINT_COMMAND_ID, + title: nls.localize('inlineBreakpoint', "Inline Breakpoint"), category: nls.localize('debug', "Debug") } }); MenuRegistry.appendMenuItem(MenuId.EditorContext, { command: { - id: COLUMN_BREAKPOINT_COMMAND_ID, - title: nls.localize('addColumnBreakpoint', "Add Column Breakpoint") + id: INLINE_BREAKPOINT_COMMAND_ID, + title: nls.localize('addInlineBreakpoint', "Add Inline Breakpoint") }, when: ContextKeyExpr.and(CONTEXT_IN_DEBUG_MODE, CONTEXT_NOT_IN_DEBUG_REPL, EditorContextKeys.writable), group: 'debug', diff --git a/src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts b/src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts index 1c04008f869e9..ad7bb41b4a4b9 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts @@ -117,8 +117,8 @@ export class DebugEditorContribution implements IDebugEditorContribution { } else if (breakpoints.length > 1) { const sorted = breakpoints.slice().sort((first, second) => first.column - second.column); actions.push(new ContextSubMenu(nls.localize('removeBreakpoints', "Remove Breakpoints"), sorted.map(bp => new Action( - 'removeColumnBreakpoint', - bp.column ? nls.localize('removeBreakpointOnColumn', "Remove Breakpoint on Column {0}", bp.column) : nls.localize('removeLineBreakpoint', "Remove Line Breakpoint"), + 'removeInlineBreakpoint', + bp.column ? nls.localize('removeInlineBreakpointOnColumn', "Remove Inline Breakpoint on Column {0}", bp.column) : nls.localize('removeLineBreakpoint', "Remove Line Breakpoint"), null, true, () => this.debugService.removeBreakpoints(bp.getId()) @@ -126,7 +126,7 @@ export class DebugEditorContribution implements IDebugEditorContribution { actions.push(new ContextSubMenu(nls.localize('editBreakpoints', "Edit Breakpoints"), sorted.map(bp => new Action('editBreakpoint', - bp.column ? nls.localize('editBreakpointOnColumn', "Edit Breakpoint on Column {0}", bp.column) : nls.localize('editLineBrekapoint', "Edit Line Breakpoint"), + bp.column ? nls.localize('editInlineBreakpointOnColumn', "Edit Inline Breakpoint on Column {0}", bp.column) : nls.localize('editLineBrekapoint', "Edit Line Breakpoint"), null, true, () => TPromise.as(this.editor.getContribution(EDITOR_CONTRIBUTION_ID).showBreakpointWidget(bp.lineNumber, bp.column)) @@ -135,8 +135,8 @@ export class DebugEditorContribution implements IDebugEditorContribution { actions.push(new ContextSubMenu(nls.localize('enableDisableBreakpoints', "Enable/Disable Breakpoints"), sorted.map(bp => new Action( bp.enabled ? 'disableColumnBreakpoint' : 'enableColumnBreakpoint', - bp.enabled ? (bp.column ? nls.localize('disableColumnBreakpoint', "Disable Breakpoint on Column {0}", bp.column) : nls.localize('disableBreakpointOnLine', "Disable Line Breakpoint")) - : (bp.column ? nls.localize('enableBreakpoints', "Enable Breakpoint on Column {0}", bp.column) : nls.localize('enableBreakpointOnLine', "Enable Line Breakpoint")), + bp.enabled ? (bp.column ? nls.localize('disableInlineColumnBreakpoint', "Disable Inline Breakpoint on Column {0}", bp.column) : nls.localize('disableBreakpointOnLine', "Disable Line Breakpoint")) + : (bp.column ? nls.localize('enableBreakpoints', "Enable Inline Breakpoint on Column {0}", bp.column) : nls.localize('enableBreakpointOnLine', "Enable Line Breakpoint")), null, true, () => this.debugService.enableOrDisableBreakpoints(!bp.enabled, bp)