diff --git a/ace/editor_highlight_selected_word_test.js b/ace/editor_highlight_selected_word_test.js index e7a5ec00..302ff3fe 100644 --- a/ace/editor_highlight_selected_word_test.js +++ b/ace/editor_highlight_selected_word_test.js @@ -73,15 +73,13 @@ var lipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " + module.exports = { - setUp: function(next) { + setUp: function() { this.buffer = new Buffer(lipsum); this.selection = this.buffer.getSelection(); this.search = new Search(); this.win = new Window({}, this.search); - this.winController = new WindowController(this.win, new WindowViewMock()); - + this.winController = new WindowController(this.win, new WindowViewMock()); this.win.setBuffer(this.buffer); - next(); }, "test: highlight selected words by default": function() { diff --git a/ace/model/window_test.js b/ace/model/window_test.js index 3b5f7c0d..1264ced8 100644 --- a/ace/model/window_test.js +++ b/ace/model/window_test.js @@ -50,17 +50,47 @@ module.exports = { setUp: function() { this.win = new Window(); + this.win.setBuffer(this.createBuffer(200, 5)); + this.win.setSizes({ + heigth: 410, + width: 640, + scrollerHeight: 400, + scrollerWidth: 600 + }); + this.win.setComputedCharacterSize({width: 10, height: 20}); + this.win.updateLayerConfig(); + }, + + createBuffer: function(rows, cols) { + var line = new Array(cols + 1).join("a"); + var text = new Array(rows).join(line + "\n") + line; + return new Buffer(text); }, "test setting a buffer chould emit a change event": function() { assert.eventFired(this.win, "changeBuffer", function() { this.win.setBuffer(new Buffer("")); }, this); + }, + + "test compute layer config when scrolled to the top": function() { + var config = this.win.layerConfig; + assert.equal(config.width, 600); + assert.equal(config.height, 400); + assert.equal(config.minHeight, 440); // ?? + assert.equal(config.maxHeight, 200*20); + assert.equal(config.offset, 0); + assert.equal(config.firstRow, 0); + assert.equal(config.lastRow, 20); + }, + + "test get last visible row": function() { + assert.equal(this.win.getLastVisibleRow(), 19); } }; }); if (typeof module !== "undefined" && module === require.main) { - require("asyncjs/test").testcase(module.exports).exec() + require("asyncjs").test.testcase(module.exports).exec() } \ No newline at end of file diff --git a/ace/view/window_view.js b/ace/view/window_view.js index 8447c154..1580ea79 100644 --- a/ace/view/window_view.js +++ b/ace/view/window_view.js @@ -127,7 +127,7 @@ var WindowView = function(windowModel, container) { oop.implement(this, EventEmitter); - // TODO refctor + // TODO refactor // remove this.setSession = function(session) { this.$textLayer.setSession(session); @@ -171,10 +171,6 @@ var WindowView = function(windowModel, container) { this.$loop.schedule(this.CHANGE_FULL); }; - this.updateFontSize = function() { - this.$textLayer.checkForSizeChanges(); - }; - this.measureSizes = function() { var width = dom.getInnerWidth(this.container); var gutterWidth = this.model.showGutter ? this.$gutter.offsetWidth : 0; diff --git a/ace/window_controller.js b/ace/window_controller.js index 4303532e..a1d065e7 100644 --- a/ace/window_controller.js +++ b/ace/window_controller.js @@ -95,10 +95,10 @@ var WindowController = exports.WindowController = function(model, view) { oldBuffer.removeListener("changeBackMarker", this._onChangeBackMarker); oldBuffer.removeListener("changeBreakpoint", this._onChangeBreakpoint); oldBuffer.removeListener("changeAnnotation", this._onChangeAnnotation); - oldBuffer.removeListener("changeOverwrite", this._onCursorChange); + oldBuffer.removeListener("changeOverwrite", this._onChangeCursor); var selection = oldBuffer.getSelection(); - selection.removeEventListener("changeCursor", this._onCursorChange); + selection.removeEventListener("changeCursor", this._onChangeCursor); selection.removeEventListener("changeSelection", this._onSelectionChange); } @@ -138,11 +138,11 @@ var WindowController = exports.WindowController = function(model, view) { this._onChangeAnnotation = this.onChangeAnnotation.bind(this); buffer.on("changeAnnotation", this._onChangeAnnotation); - this._onCursorChange = this.onCursorChange.bind(this); - buffer.on("changeOverwrite", this._onCursorChange); + this._onChangeCursor = this.onChangeCursor.bind(this); + buffer.on("changeOverwrite", this._onChangeCursor); this.selection = buffer.getSelection(); - this.selection.on("changeCursor", this._onCursorChange); + this.selection.on("changeCursor", this._onChangeCursor); this._onSelectionChange = this.onSelectionChange.bind(this); this.selection.on("changeSelection", this._onSelectionChange); @@ -154,7 +154,7 @@ var WindowController = exports.WindowController = function(model, view) { if (buffer.getUseWrapMode()) this.view.adjustWrapLimit(); - this.onCursorChange(); + this.onChangeCursor(); this.onSelectionChange(); this.view.updateFull(); @@ -199,7 +199,7 @@ var WindowController = exports.WindowController = function(model, view) { this.view.setAnnotations(this.model.buffer.getAnnotations()); }; - this.onCursorChange = function(e) { + this.onChangeCursor = function(e) { this.view.updateCursor(); this.model.scrollCursorIntoView();