Commit 39f0224d authored by Joel Einbinder's avatar Joel Einbinder Committed by Commit Bot

DevTools: Remove custom auto-close quote impementation

In 2014, CodeMirror had poor support for auto-closing quotes. In
response to bug 411238, a custom implementation of auto-closing
quotes was added. This assumed a US keyboard layout, and broke
some international keyboards.

CodeMirror has much better support for auto-closing quotes now,
so this patch removes the legacy code.

Bug: 578852
Change-Id: I9b80e6f628adadc7b37c39dab7be5eaa0c76d7a9
Reviewed-on: https://chromium-review.googlesource.com/830650Reviewed-by: default avatarAndrey Lushnikov <lushnikov@chromium.org>
Commit-Queue: Joel Einbinder <einbinder@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524552}
parent 6f291820
......@@ -141,8 +141,6 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
this._codeMirror.setOption('keyMap', Host.isMac() ? 'devtools-mac' : 'devtools-pc');
this._codeMirror.addKeyMap({'\'': 'maybeAvoidSmartSingleQuotes', '\'"\'': 'maybeAvoidSmartDoubleQuotes'});
this._codeMirror.setOption('flattenSpans', false);
var maxHighlightLength = options.maxHighlightLength;
......@@ -232,30 +230,6 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
codeMirror._codeMirrorTextEditor._doCamelCaseMovement(1, shift);
}
/**
* @param {string} quoteCharacter
* @param {!CodeMirror} codeMirror
* @return {*}
*/
static _maybeAvoidSmartQuotes(quoteCharacter, codeMirror) {
var textEditor = codeMirror._codeMirrorTextEditor;
if (!codeMirror.getOption('autoCloseBrackets'))
return CodeMirror.Pass;
var selections = textEditor.selections();
if (selections.length !== 1 || !selections[0].isEmpty())
return CodeMirror.Pass;
var selection = selections[0];
var token = textEditor.tokenAtTextPosition(selection.startLine, selection.startColumn);
if (!token || !token.type || token.type.indexOf('string') === -1)
return CodeMirror.Pass;
var line = textEditor.line(selection.startLine);
var tokenValue = line.substring(token.startColumn, token.endColumn);
if (tokenValue[0] === tokenValue[tokenValue.length - 1] && (tokenValue[0] === '\'' || tokenValue[0] === '"'))
return CodeMirror.Pass;
codeMirror.replaceSelection(quoteCharacter);
}
/**
* @param {string} modeName
* @param {string} tokenPrefix
......@@ -1401,12 +1375,6 @@ CodeMirror.commands.goSmartPageDown = function(codemirror) {
codemirror.execCommand('goPageDown');
};
CodeMirror.commands.maybeAvoidSmartSingleQuotes =
TextEditor.CodeMirrorTextEditor._maybeAvoidSmartQuotes.bind(null, '\'');
CodeMirror.commands.maybeAvoidSmartDoubleQuotes =
TextEditor.CodeMirrorTextEditor._maybeAvoidSmartQuotes.bind(null, '"');
TextEditor.CodeMirrorTextEditor.LongLineModeLineLengthThreshold = 2000;
TextEditor.CodeMirrorTextEditor.MaxEditableTextSize = 1024 * 1024 * 10;
......
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