Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1884)

Unified Diff: Source/devtools/front_end/source_frame/CodeMirrorTextEditor.js

Issue 402433007: DevTools: [CodeMirror] remove auto-inserted whitespaces (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebaseline inspector/editor/text-editor-formatter.html Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/inspector/editor/text-editor-formatter-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/source_frame/CodeMirrorTextEditor.js
diff --git a/Source/devtools/front_end/source_frame/CodeMirrorTextEditor.js b/Source/devtools/front_end/source_frame/CodeMirrorTextEditor.js
index 8d6755e76878ea93a4928231960dc2f6c35540b4..f72cd5031e34b99f0409edad5ce3efe339c5c51b 100644
--- a/Source/devtools/front_end/source_frame/CodeMirrorTextEditor.js
+++ b/Source/devtools/front_end/source_frame/CodeMirrorTextEditor.js
@@ -248,6 +248,7 @@ CodeMirror.commands.smartNewlineAndIndent = function(codeMirror)
replacements.push("\n" + indent.substring(0, Math.min(cur.ch, indent.length)));
}
codeMirror.replaceSelections(replacements);
+ codeMirror._codeMirrorTextEditor._onAutoAppendedSpaces();
}
}
@@ -325,6 +326,25 @@ WebInspector.CodeMirrorTextEditor.MaximumNumberOfWhitespacesPerSingleSpan = 16;
WebInspector.CodeMirrorTextEditor.MaxEditableTextSize = 1024 * 1024 * 10;
WebInspector.CodeMirrorTextEditor.prototype = {
+ _onAutoAppendedSpaces: function()
+ {
+ this._autoAppendedSpaces = this._autoAppendedSpaces || [];
+ for (var i = 0; i < this._autoAppendedSpaces.length; ++i) {
+ var position = this._autoAppendedSpaces[i].resolve();
+ if (!position)
+ continue;
+ var line = this.line(position.lineNumber);
+ if (line.length === position.columnNumber && WebInspector.TextUtils.lineIndent(line).length === line.length)
+ this._codeMirror.replaceRange("", new CodeMirror.Pos(position.lineNumber, 0), new CodeMirror.Pos(position.lineNumber, position.columnNumber));
+ }
+ this._autoAppendedSpaces = [];
+ var selections = this.selections();
+ for (var i = 0; i < selections.length; ++i) {
+ var selection = selections[i];
+ this._autoAppendedSpaces.push(this.textEditorPositionHandle(selection.startLine, selection.startColumn));
+ }
+ },
+
/**
* @param {number} lineNumber
* @param {number} lineLength
@@ -1701,8 +1721,10 @@ WebInspector.CodeMirrorTextEditor.BlockIndentController.prototype = {
allSelectionsAreCollapsedBlocks = isCollapsedBlock;
}
codeMirror.replaceSelections(replacements);
- if (!allSelectionsAreCollapsedBlocks)
+ if (!allSelectionsAreCollapsedBlocks) {
+ codeMirror._codeMirrorTextEditor._onAutoAppendedSpaces();
return;
+ }
selections = codeMirror.listSelections();
var updatedSelections = [];
for (var i = 0; i < selections.length; ++i) {
@@ -1715,6 +1737,7 @@ WebInspector.CodeMirrorTextEditor.BlockIndentController.prototype = {
});
}
codeMirror.setSelections(updatedSelections);
+ codeMirror._codeMirrorTextEditor._onAutoAppendedSpaces();
},
/**
« no previous file with comments | « LayoutTests/inspector/editor/text-editor-formatter-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698