Commit 770b1dc2 authored by Fabio Rocha's avatar Fabio Rocha Committed by Commit Bot

DevTools: Fix small bug where Console shortcuts were only displayed if Console...

DevTools: Fix small bug where Console shortcuts were only displayed if Console had been previously launched

The Console shortcuts were only displayed in the shortcuts panel (in Settings) if the Console had been loaded previously, otherwise the Console shortcuts section would be empty.

The reason was that the Console's descriptors weren't registered in the same place as all the other shortcut descriptors.

The fix was a small refactor to extract descriptors into ShortcutScreen.js. Also did some cleanup in there to improve consistency.

Change-Id: Ifee95da25208c6eace4a5be9775432bfb1880138
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1625926Reviewed-by: default avatarJoel Einbinder <einbinder@chromium.org>
Commit-Queue: Fabio Rocha <fabio.rocha@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#663949}
parent 6f6e22d7
...@@ -924,35 +924,8 @@ Console.ConsoleView = class extends UI.VBox { ...@@ -924,35 +924,8 @@ Console.ConsoleView = class extends UI.VBox {
_registerShortcuts() { _registerShortcuts() {
this._shortcuts = {}; this._shortcuts = {};
this._shortcuts[UI.KeyboardShortcut.makeKey('u', UI.KeyboardShortcut.Modifiers.Ctrl)] =
const shortcut = UI.KeyboardShortcut; this._clearPromptBackwards.bind(this);
const section = UI.shortcutsScreen.section(Common.UIString('Console'));
const shortcutL = shortcut.makeDescriptor('l', UI.KeyboardShortcut.Modifiers.Ctrl);
let keys = [shortcutL];
if (Host.isMac()) {
const shortcutK = shortcut.makeDescriptor('k', UI.KeyboardShortcut.Modifiers.Meta);
keys.unshift(shortcutK);
}
section.addAlternateKeys(keys, Common.UIString('Clear console'));
keys = [shortcut.makeDescriptor(shortcut.Keys.Tab), shortcut.makeDescriptor(shortcut.Keys.Right)];
section.addRelatedKeys(keys, Common.UIString('Accept suggestion'));
const shortcutU = shortcut.makeDescriptor('u', UI.KeyboardShortcut.Modifiers.Ctrl);
this._shortcuts[shortcutU.key] = this._clearPromptBackwards.bind(this);
section.addAlternateKeys([shortcutU], Common.UIString('Clear console prompt'));
keys = [shortcut.makeDescriptor(shortcut.Keys.Down), shortcut.makeDescriptor(shortcut.Keys.Up)];
section.addRelatedKeys(keys, Common.UIString('Next/previous line'));
if (Host.isMac()) {
keys =
[shortcut.makeDescriptor('N', shortcut.Modifiers.Alt), shortcut.makeDescriptor('P', shortcut.Modifiers.Alt)];
section.addRelatedKeys(keys, Common.UIString('Next/previous command'));
}
section.addKey(shortcut.makeDescriptor(shortcut.Keys.Enter), Common.UIString('Execute command'));
} }
_clearPromptBackwards() { _clearPromptBackwards() {
......
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