Commit 8a631993 authored by Erik Luo's avatar Erik Luo Committed by Commit Bot

DevTools: allow ShiftTab to focus away from CodeMirror

CodeMirror text editors try to reduce indentation on 'Shift+Tab'.
However, this consumes the key event, preventing focus from leaving,
even if nothing changed.

This CL allows focus to leave when we are sure that no indentation
should change. Shift+Tab can now move focus from Console prompt to
toolbar and from SourceFrame's editor to the Sources TabbedPane.

Bug: none
Change-Id: I3660a48fe1c30a0972e2908514ee44fba7a51132
Reviewed-on: https://chromium-review.googlesource.com/1142519
Commit-Queue: Erik Luo <luoe@chromium.org>
Reviewed-by: default avatarAndrey Lushnikov <lushnikov@chromium.org>
Reviewed-by: default avatarJoel Einbinder <einbinder@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577406}
parent 127fe20d
......@@ -74,7 +74,7 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
'Delete': 'delCharAfter',
'Backspace': 'delCharBefore',
'Tab': 'defaultTab',
'Shift-Tab': 'indentLess',
'Shift-Tab': 'indentLessOrPass',
'Enter': 'newlineAndIndent',
'Ctrl-Space': 'autocomplete',
'Esc': 'dismiss',
......@@ -1324,6 +1324,20 @@ CodeMirror.commands.selectCamelLeft = TextEditor.CodeMirrorTextEditor.moveCamelL
CodeMirror.commands.moveCamelRight = TextEditor.CodeMirrorTextEditor.moveCamelRightCommand.bind(null, false);
CodeMirror.commands.selectCamelRight = TextEditor.CodeMirrorTextEditor.moveCamelRightCommand.bind(null, true);
/**
* @param {!CodeMirror} codeMirror
* @return {!Object|undefined}
*/
CodeMirror.commands.indentLessOrPass = function(codeMirror) {
const selections = codeMirror.listSelections();
if (selections.length === 1) {
const range = TextEditor.CodeMirrorUtils.toRange(selections[0].anchor, selections[0].head);
if (range.isEmpty() && !/^\s/.test(codeMirror.getLine(range.startLine)))
return CodeMirror.Pass;
}
codeMirror.execCommand('indentLess');
};
/**
* @param {!CodeMirror} codeMirror
*/
......@@ -1371,6 +1385,7 @@ CodeMirror.commands.redoAndReveal = function(codemirror) {
};
/**
* @param {!CodeMirror} codemirror
* @return {!Object|undefined}
*/
CodeMirror.commands.dismiss = function(codemirror) {
......@@ -1389,6 +1404,7 @@ CodeMirror.commands.dismiss = function(codemirror) {
};
/**
* @param {!CodeMirror} codemirror
* @return {!Object|undefined}
*/
CodeMirror.commands.goSmartPageUp = function(codemirror) {
......@@ -1398,6 +1414,7 @@ CodeMirror.commands.goSmartPageUp = function(codemirror) {
};
/**
* @param {!CodeMirror} codemirror
* @return {!Object|undefined}
*/
CodeMirror.commands.goSmartPageDown = function(codemirror) {
......
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