Commit b66e999e authored by luoe's avatar luoe Committed by Commit Bot

DevTools: align keyboard shortcut with mouse action to toggle breakpoint enabled

Cmd+B and gutter click both toggle breakpoint on a line. Gutter click + shift
also disabled the current breakpoint. This CL aligns Cmd+Shift+B to disable the
current breakpoint as well.

BUG=741115

Review-Url: https://codereview.chromium.org/2977753002
Cr-Commit-Position: refs/heads/master@{#486152}
parent 7d938ad5
...@@ -1568,14 +1568,17 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame { ...@@ -1568,14 +1568,17 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame {
} }
} }
toggleBreakpointOnCurrentLine() { /**
* @param {boolean} onlyDisable
*/
toggleBreakpointOnCurrentLine(onlyDisable) {
if (this._muted) if (this._muted)
return; return;
var selection = this.textEditor.selection(); var selection = this.textEditor.selection();
if (!selection) if (!selection)
return; return;
this._toggleBreakpoint(selection.startLine, false); this._toggleBreakpoint(selection.startLine, onlyDisable);
} }
/** /**
......
...@@ -153,7 +153,11 @@ Sources.SourcesView = class extends UI.VBox { ...@@ -153,7 +153,11 @@ Sources.SourcesView = class extends UI.VBox {
registerShortcut.call( registerShortcut.call(
this, UI.ShortcutsScreen.SourcesPanelShortcuts.GoToMember, this._showOutlineQuickOpen.bind(this)); this, UI.ShortcutsScreen.SourcesPanelShortcuts.GoToMember, this._showOutlineQuickOpen.bind(this));
registerShortcut.call( registerShortcut.call(
this, UI.ShortcutsScreen.SourcesPanelShortcuts.ToggleBreakpoint, this._toggleBreakpoint.bind(this)); this, UI.ShortcutsScreen.SourcesPanelShortcuts.ToggleBreakpoint,
this._toggleBreakpoint.bind(this, false /* onlyDisable */));
registerShortcut.call(
this, UI.ShortcutsScreen.SourcesPanelShortcuts.ToggleBreakpointEnabled,
this._toggleBreakpoint.bind(this, true /* onlyDisable */));
registerShortcut.call(this, UI.ShortcutsScreen.SourcesPanelShortcuts.Save, this._save.bind(this)); registerShortcut.call(this, UI.ShortcutsScreen.SourcesPanelShortcuts.Save, this._save.bind(this));
registerShortcut.call(this, UI.ShortcutsScreen.SourcesPanelShortcuts.SaveAll, this._saveAll.bind(this)); registerShortcut.call(this, UI.ShortcutsScreen.SourcesPanelShortcuts.SaveAll, this._saveAll.bind(this));
} }
...@@ -660,16 +664,17 @@ Sources.SourcesView = class extends UI.VBox { ...@@ -660,16 +664,17 @@ Sources.SourcesView = class extends UI.VBox {
} }
/** /**
* @param {boolean} onlyDisable
* @return {boolean} * @return {boolean}
*/ */
_toggleBreakpoint() { _toggleBreakpoint(onlyDisable) {
var sourceFrame = this.currentSourceFrame(); var sourceFrame = this.currentSourceFrame();
if (!sourceFrame) if (!sourceFrame)
return false; return false;
if (sourceFrame instanceof Sources.JavaScriptSourceFrame) { if (sourceFrame instanceof Sources.JavaScriptSourceFrame) {
var javaScriptSourceFrame = /** @type {!Sources.JavaScriptSourceFrame} */ (sourceFrame); var javaScriptSourceFrame = /** @type {!Sources.JavaScriptSourceFrame} */ (sourceFrame);
javaScriptSourceFrame.toggleBreakpointOnCurrentLine(); javaScriptSourceFrame.toggleBreakpointOnCurrentLine(onlyDisable);
return true; return true;
} }
return false; return false;
......
...@@ -105,6 +105,8 @@ UI.ShortcutsScreen = class { ...@@ -105,6 +105,8 @@ UI.ShortcutsScreen = class {
UI.ShortcutsScreen.SourcesPanelShortcuts.AddSelectionToWatch, Common.UIString('Add selection to watch')); UI.ShortcutsScreen.SourcesPanelShortcuts.AddSelectionToWatch, Common.UIString('Add selection to watch'));
section.addAlternateKeys( section.addAlternateKeys(
UI.ShortcutsScreen.SourcesPanelShortcuts.ToggleBreakpoint, Common.UIString('Toggle breakpoint')); UI.ShortcutsScreen.SourcesPanelShortcuts.ToggleBreakpoint, Common.UIString('Toggle breakpoint'));
section.addAlternateKeys(
UI.ShortcutsScreen.SourcesPanelShortcuts.ToggleBreakpointEnabled, Common.UIString('Toggle breakpoint enabled'));
section.addAlternateKeys( section.addAlternateKeys(
UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoints-active'), UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoints-active'),
Common.UIString('Toggle all breakpoints')); Common.UIString('Toggle all breakpoints'));
...@@ -432,6 +434,9 @@ UI.ShortcutsScreen.SourcesPanelShortcuts = { ...@@ -432,6 +434,9 @@ UI.ShortcutsScreen.SourcesPanelShortcuts = {
ToggleBreakpoint: [UI.KeyboardShortcut.makeDescriptor('b', UI.KeyboardShortcut.Modifiers.CtrlOrMeta)], ToggleBreakpoint: [UI.KeyboardShortcut.makeDescriptor('b', UI.KeyboardShortcut.Modifiers.CtrlOrMeta)],
ToggleBreakpointEnabled: [UI.KeyboardShortcut.makeDescriptor(
'b', UI.KeyboardShortcut.Modifiers.CtrlOrMeta | UI.KeyboardShortcut.Modifiers.Shift)],
NextCallFrame: NextCallFrame:
[UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Period, UI.KeyboardShortcut.Modifiers.Ctrl)], [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Period, UI.KeyboardShortcut.Modifiers.Ctrl)],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment