Make all tests pass again

This commit is contained in:
Julian Viereck 2011-01-27 00:25:19 +01:00
commit fc111989ec
5 changed files with 22 additions and 10 deletions

View file

@ -318,18 +318,18 @@ var EditSession = function(text, mode) {
};
this.getWidth = function() {
this.$computeWidth(!this.width);
this.$computeWidth();
return this.width;
};
this.getScreenWidth = function() {
this.$computeWidth(!this.screenWidth);
this.$computeWidth();
return this.screenWidth;
};
this.$computeWidth = function(force) {
if (this.modified || force) {
this.modified = false;
if (this.$modified || force) {
this.$modified = false;
var lines = this.doc.getAllLines();
var longestLine = 0;
@ -340,7 +340,7 @@ var EditSession = function(text, mode) {
var len = lines[i].length;
longestLine = Math.max(longestLine, len);
lines[i].replace("\t", function(m) {
lines[i].replace(/\t/g, function(m) {
len += tabSize-1;
return m;
});

View file

@ -56,15 +56,17 @@ var TextInput = function(parentNode, host) {
style.opacity = 0;
style.width = "10px";
style.height = "30px";
var changeCursor = function() {
if (host.renderer.isMockRenderer) return;
var cursor = host.getCursorPosition();
var pos = host.renderer.textToScreenCoordinates(cursor.row, cursor.column);
var epos = parentNode.getBoundingClientRect();
style.left = (pos.pageX - epos.left - 6) + "px";
style.top = (pos.pageY - epos.top + 52) + "px";
};
host.addEventListener("changeSession", function(e) {
if (e.oldSession)
e.oldSession.getSelection().removeEventListener("changeCursor", changeCursor);

View file

@ -285,7 +285,7 @@ var Test = {
var splits;
var tabSize = 4;
var wrapLimit = 12;
var computeWrapSplits = Document.prototype.$computeWrapSplits;
var computeWrapSplits = EditSession.prototype.$computeWrapSplits;
var c = 0;
function computeAndAssert(line, assertEqual) {

View file

@ -257,6 +257,7 @@ var Test = {
session.doc.insertNewLine(0);
session.doc.insertLines(1, ["\t\t"]);
assert.equal(session.getWidth(), 3);
assert.equal(session.getScreenWidth(), 8);

View file

@ -50,6 +50,8 @@ MockRenderer = function(visibleRowCount) {
firstVisibleRow : 0,
lastVisibleRow : this.visibleRowCount
};
this.isMockRenderer = true;
};
@ -117,10 +119,10 @@ MockRenderer.prototype.addMarker = function() {
MockRenderer.prototype.setBreakpoints = function() {
};
MockRenderer.prototype.updateFull = function() {
MockRenderer.prototype.updateFull = function() {
};
MockRenderer.prototype.updateText = function() {
MockRenderer.prototype.updateText = function() {
};
MockRenderer.prototype.showCursor = function() {
@ -132,5 +134,12 @@ MockRenderer.prototype.visualizeFocus = function() {
MockRenderer.prototype.setAnnotations = function() {
};
MockRenderer.prototype.textToScreenCoordinates = function() {
return {
pageX: 0,
pageY: 0
}
};
return MockRenderer;
});