Permalink
Browse files

perf fix when editor contains a huge number of lines.

Issue was: resizing the editor for every textual addition and keeping the whole
editor visible makes it slow with a great number of lines.
  • Loading branch information...
1 parent 073a288 commit 5f60d52eb8a46812d17e4b047bcd8dccc2306bb5 @espadrine espadrine committed Jul 24, 2012
Showing with 8 additions and 3 deletions.
  1. +8 −3 chrome/jsterm.js
  2. BIN jsterm.xpi
View
@@ -16,7 +16,6 @@ Cu.import("resource:///modules/WebConsoleUtils.jsm");
*/
const JSTERM_MARK = "orion.annotation.jstermobject";
-const PRINT_TIMEOUT = 17; // Every 17 ms → 60fps.
let JSTermUI = {
input: new SourceEditor(),
@@ -150,7 +149,7 @@ let JSTermUI = {
this.printedSomething = true;
this.output.setText(this.printQueue, this.output.getCharCount());
this.printQueue = "";
- }.bind(this), PRINT_TIMEOUT);
+ }.bind(this), 0);
},
initOutput: function() {
@@ -191,9 +190,15 @@ let JSTermUI = {
},
setEditorSize: function(e, height) {
+ let winHeight = e.editorElement.ownerDocument.defaultView.innerHeight;
+ // We want to resize if the editor doesn't overflow on the Y axis.
e.editorElement.style.minHeight =
e.editorElement.style.maxHeight =
- e.editorElement.style.height = (height) + "px";
+ e.editorElement.style.height =
+ (e._view.getLineHeight() * e.getLineCount() +
+ this.input.editorElement.scrollHeight <= winHeight
+ ? (height) + "px"
+ : "");
},
ensureInputIsAlwaysVisible: function(editor) {
View
Binary file not shown.

0 comments on commit 5f60d52

Please sign in to comment.