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

Unified Diff: third_party/WebKit/Source/devtools/front_end/text_editor/CodeMirrorTextEditor.js

Issue 2574443003: [DevTools] Make line highlight stay in readonly editor. (Closed)
Patch Set: Created 4 years 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 | « no previous file | third_party/WebKit/Source/devtools/front_end/text_editor/cmdevtools.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 acd1700a50e37d5617fd8b82173e593c615c9980..0310ab642ec1be3737dfcf21d0a85613efa68e33 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
@@ -172,6 +172,8 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
this._needsRefresh = true;
+ this._readOnly = false;
+
this._mimeType = '';
if (options.mimeType)
this.setMimeType(options.mimeType);
@@ -711,6 +713,10 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
* @param {boolean} readOnly
*/
setReadOnly(readOnly) {
+ if (this._readOnly === readOnly)
+ return;
+ this.clearPositionHighlight();
+ this._readOnly = readOnly;
this.element.classList.toggle('CodeMirror-readonly', readOnly);
this._codeMirror.setOption('readOnly', readOnly);
}
@@ -903,8 +909,10 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
return;
this.scrollLineIntoView(lineNumber);
if (shouldHighlight) {
- this._codeMirror.addLineClass(this._highlightedLine, null, 'cm-highlight');
- this._clearHighlightTimeout = setTimeout(this.clearPositionHighlight.bind(this), 2000);
+ this._codeMirror.addLineClass(
+ this._highlightedLine, null, this._readOnly ? 'cm-readonly-highlight' : 'cm-highlight');
+ if (!this._readOnly)
+ this._clearHighlightTimeout = setTimeout(this.clearPositionHighlight.bind(this), 2000);
}
this.setSelection(Common.TextRange.createFromLocation(lineNumber, columnNumber));
}
@@ -914,8 +922,10 @@ TextEditor.CodeMirrorTextEditor = class extends UI.VBox {
clearTimeout(this._clearHighlightTimeout);
delete this._clearHighlightTimeout;
- if (this._highlightedLine)
- this._codeMirror.removeLineClass(this._highlightedLine, null, 'cm-highlight');
+ if (this._highlightedLine) {
+ this._codeMirror.removeLineClass(
+ this._highlightedLine, null, this._readOnly ? 'cm-readonly-highlight' : 'cm-highlight');
+ }
delete this._highlightedLine;
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/text_editor/cmdevtools.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698