| Index: third_party/WebKit/Source/devtools/front_end/text_editor/CodeMirrorTextEditor.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/text_editor/CodeMirrorTextEditor.js b/third_party/WebKit/Source/devtools/front_end/text_editor/CodeMirrorTextEditor.js
|
| index db077fbe060113505cf4b31cb4cbccc564676ecd..4748d71140121439320b5d6222ca89648eed43c9 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/text_editor/CodeMirrorTextEditor.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/text_editor/CodeMirrorTextEditor.js
|
| @@ -141,7 +141,8 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
|
| this._shouldClearHistory = true;
|
| this._lineSeparator = '\n';
|
|
|
| - this._fixWordMovement = new TextEditor.CodeMirrorTextEditor.FixWordMovement(this._codeMirror);
|
| + TextEditor.CodeMirrorTextEditor._fixWordMovement(this._codeMirror);
|
| +
|
| this._selectNextOccurrenceController =
|
| new TextEditor.CodeMirrorTextEditor.SelectNextOccurrenceController(this, this._codeMirror);
|
|
|
| @@ -155,7 +156,6 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
|
|
|
| /** @type {!Multimap<number, !TextEditor.CodeMirrorTextEditor.Decoration>} */
|
| this._decorations = new Multimap();
|
| - this._nestedUpdatesCounter = 0;
|
|
|
| this.element.addEventListener('focus', this._handleElementFocus.bind(this), false);
|
| this.element.addEventListener('keydown', this._handleKeyDown.bind(this), true);
|
| @@ -314,6 +314,53 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
|
| }
|
|
|
| /**
|
| + * @param {!CodeMirror} codeMirror
|
| + */
|
| + static _fixWordMovement(codeMirror) {
|
| + function moveLeft(shift, codeMirror) {
|
| + codeMirror.setExtending(shift);
|
| + var cursor = codeMirror.getCursor('head');
|
| + codeMirror.execCommand('goGroupLeft');
|
| + var newCursor = codeMirror.getCursor('head');
|
| + if (newCursor.ch === 0 && newCursor.line !== 0) {
|
| + codeMirror.setExtending(false);
|
| + return;
|
| + }
|
| +
|
| + var skippedText = codeMirror.getRange(newCursor, cursor, '#');
|
| + if (/^\s+$/.test(skippedText))
|
| + codeMirror.execCommand('goGroupLeft');
|
| + codeMirror.setExtending(false);
|
| + }
|
| +
|
| + function moveRight(shift, codeMirror) {
|
| + codeMirror.setExtending(shift);
|
| + var cursor = codeMirror.getCursor('head');
|
| + codeMirror.execCommand('goGroupRight');
|
| + var newCursor = codeMirror.getCursor('head');
|
| + if (newCursor.ch === 0 && newCursor.line !== 0) {
|
| + codeMirror.setExtending(false);
|
| + return;
|
| + }
|
| +
|
| + var skippedText = codeMirror.getRange(cursor, newCursor, '#');
|
| + if (/^\s+$/.test(skippedText))
|
| + codeMirror.execCommand('goGroupRight');
|
| + codeMirror.setExtending(false);
|
| + }
|
| +
|
| + var modifierKey = Host.isMac() ? 'Alt' : 'Ctrl';
|
| + var leftKey = modifierKey + '-Left';
|
| + var rightKey = modifierKey + '-Right';
|
| + var keyMap = {};
|
| + keyMap[leftKey] = moveLeft.bind(null, false);
|
| + keyMap[rightKey] = moveRight.bind(null, false);
|
| + keyMap['Shift-' + leftKey] = moveLeft.bind(null, true);
|
| + keyMap['Shift-' + rightKey] = moveRight.bind(null, true);
|
| + codeMirror.addKeyMap(keyMap);
|
| + }
|
| +
|
| + /**
|
| * @protected
|
| * @return {!CodeMirror}
|
| */
|
| @@ -1323,58 +1370,6 @@ TextEditor.CodeMirrorPositionHandle = class {
|
| /**
|
| * @unrestricted
|
| */
|
| -TextEditor.CodeMirrorTextEditor.FixWordMovement = class {
|
| - /**
|
| - * @param {!CodeMirror} codeMirror
|
| - */
|
| - constructor(codeMirror) {
|
| - function moveLeft(shift, codeMirror) {
|
| - codeMirror.setExtending(shift);
|
| - var cursor = codeMirror.getCursor('head');
|
| - codeMirror.execCommand('goGroupLeft');
|
| - var newCursor = codeMirror.getCursor('head');
|
| - if (newCursor.ch === 0 && newCursor.line !== 0) {
|
| - codeMirror.setExtending(false);
|
| - return;
|
| - }
|
| -
|
| - var skippedText = codeMirror.getRange(newCursor, cursor, '#');
|
| - if (/^\s+$/.test(skippedText))
|
| - codeMirror.execCommand('goGroupLeft');
|
| - codeMirror.setExtending(false);
|
| - }
|
| -
|
| - function moveRight(shift, codeMirror) {
|
| - codeMirror.setExtending(shift);
|
| - var cursor = codeMirror.getCursor('head');
|
| - codeMirror.execCommand('goGroupRight');
|
| - var newCursor = codeMirror.getCursor('head');
|
| - if (newCursor.ch === 0 && newCursor.line !== 0) {
|
| - codeMirror.setExtending(false);
|
| - return;
|
| - }
|
| -
|
| - var skippedText = codeMirror.getRange(cursor, newCursor, '#');
|
| - if (/^\s+$/.test(skippedText))
|
| - codeMirror.execCommand('goGroupRight');
|
| - codeMirror.setExtending(false);
|
| - }
|
| -
|
| - var modifierKey = Host.isMac() ? 'Alt' : 'Ctrl';
|
| - var leftKey = modifierKey + '-Left';
|
| - var rightKey = modifierKey + '-Right';
|
| - var keyMap = {};
|
| - keyMap[leftKey] = moveLeft.bind(null, false);
|
| - keyMap[rightKey] = moveRight.bind(null, false);
|
| - keyMap['Shift-' + leftKey] = moveLeft.bind(null, true);
|
| - keyMap['Shift-' + rightKey] = moveRight.bind(null, true);
|
| - codeMirror.addKeyMap(keyMap);
|
| - }
|
| -};
|
| -
|
| -/**
|
| - * @unrestricted
|
| - */
|
| TextEditor.CodeMirrorTextEditor.SelectNextOccurrenceController = class {
|
| /**
|
| * @param {!TextEditor.CodeMirrorTextEditor} textEditor
|
|
|