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); |
}, |