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

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

Issue 2331053002: DevTools: Implement the console prompt with CodeMirror (Closed)
Patch Set: Merge with PageUp fix Created 4 years, 3 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
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 2734f7844e7dffa77ee8322a1176be611da526fd..ad20610c0064b8d5666d888fb959aa45e29ec7d5 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
@@ -64,8 +64,8 @@ WebInspector.CodeMirrorTextEditor = function(options)
"Down": "goLineDown",
"End": "goLineEnd",
"Home": "goLineStartSmart",
- "PageUp": "goPageUp",
- "PageDown": "goPageDown",
+ "PageUp": "smartPageUp",
+ "PageDown": "smartPageDown",
"Delete": "delCharAfter",
"Backspace": "delCharBefore",
"Tab": "defaultTab",
@@ -162,6 +162,8 @@ WebInspector.CodeMirrorTextEditor = function(options)
this.element.tabIndex = 0;
if (options.mimeType)
this.setMimeType(options.mimeType);
+ if (options.autoHeight)
+ this._codeMirror.setSize(null, "auto");
}
WebInspector.CodeMirrorTextEditor.maxHighlightLength = 1000;
@@ -289,6 +291,26 @@ CodeMirror.commands.dismiss = function(codemirror)
}
/**
+ * @return {!Object|undefined}
+ */
+CodeMirror.commands.smartPageUp = function(codemirror)
+{
+ if (codemirror._codeMirrorTextEditor.selection().equal(WebInspector.TextRange.createFromLocation(0, 0)))
+ return CodeMirror.Pass;
+ codemirror.execCommand("goPageUp");
+}
+
+/**
+ * @return {!Object|undefined}
+ */
+CodeMirror.commands.smartPageDown = function(codemirror)
+{
+ if (codemirror._codeMirrorTextEditor.selection().equal(codemirror._codeMirrorTextEditor.fullRange().collapseToEnd()))
+ return CodeMirror.Pass;
+ codemirror.execCommand("goPageDown");
+}
+
+/**
* @param {string} quoteCharacter
* @param {!CodeMirror} codeMirror
* @return {*}
@@ -959,8 +981,12 @@ WebInspector.CodeMirrorTextEditor.prototype = {
var scrollTop = this._codeMirror.doc.scrollTop;
var width = parentElement.offsetWidth;
var height = parentElement.offsetHeight - this.element.offsetTop;
- this._codeMirror.setSize(width, height);
- this._updatePaddingBottom(width, height);
+ if (this._options.autoHeight) {
+ this._codeMirror.setSize(width, "auto");
+ } else {
+ this._codeMirror.setSize(width, height);
+ this._updatePaddingBottom(width, height);
+ }
this._codeMirror.scrollTo(scrollLeft, scrollTop);
},

Powered by Google App Engine
This is Rietveld 408576698