minor fixes
This commit is contained in:
parent
1b5c3b29ab
commit
c372ec5c9a
4 changed files with 41 additions and 17 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue