fix longest line computation
This commit is contained in:
parent
e59bc99a47
commit
a08f880b3c
2 changed files with 24 additions and 3 deletions
|
|
@ -48,7 +48,7 @@ var Document = require("ace/document").Document;
|
||||||
var NO_CHANGE_DELTAS = {};
|
var NO_CHANGE_DELTAS = {};
|
||||||
|
|
||||||
var EditSession = function(text, mode) {
|
var EditSession = function(text, mode) {
|
||||||
this.modified = true;
|
this.$modified = true;
|
||||||
this.selection = new Selection(this);
|
this.selection = new Selection(this);
|
||||||
this.$breakpoints = [];
|
this.$breakpoints = [];
|
||||||
|
|
||||||
|
|
@ -294,7 +294,7 @@ var EditSession = function(text, mode) {
|
||||||
var len = lines[i].length;
|
var len = lines[i].length;
|
||||||
longestLine = Math.max(longestLine, len);
|
longestLine = Math.max(longestLine, len);
|
||||||
|
|
||||||
lines[i].replace("\t", function(m) {
|
lines[i].replace(/\t/g, function(m) {
|
||||||
len += tabSize-1;
|
len += tabSize-1;
|
||||||
return m;
|
return m;
|
||||||
});
|
});
|
||||||
|
|
@ -512,7 +512,7 @@ var EditSession = function(text, mode) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.indentRows = function(startRow, endRow, indentString) {
|
this.indentRows = function(startRow, endRow, indentString) {
|
||||||
indentString = indentString.replace("\t", this.getTabString());
|
indentString = indentString.replace(/\t/g, this.getTabString());
|
||||||
for (var row=startRow; row<=endRow; row++) {
|
for (var row=startRow; row<=endRow; row++) {
|
||||||
this.insert({row: row, column:0}, indentString);
|
this.insert({row: row, column:0}, indentString);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -242,6 +242,27 @@ var Test = {
|
||||||
|
|
||||||
undoManager.redo();
|
undoManager.redo();
|
||||||
assert.equal(session.getValue(), ["1", "", "ad"].join("\n"));
|
assert.equal(session.getValue(), ["1", "", "ad"].join("\n"));
|
||||||
|
},
|
||||||
|
|
||||||
|
"test get longest line" : function() {
|
||||||
|
var session = new EditSession(["12"]);
|
||||||
|
session.setTabSize(4);
|
||||||
|
assert.equal(session.getWidth(), 2);
|
||||||
|
assert.equal(session.getScreenWidth(), 2);
|
||||||
|
|
||||||
|
session.doc.insertNewLine(0);
|
||||||
|
session.doc.insertLines(1, ["123"]);
|
||||||
|
assert.equal(session.getWidth(), 3);
|
||||||
|
assert.equal(session.getScreenWidth(), 3);
|
||||||
|
|
||||||
|
session.doc.insertNewLine(0);
|
||||||
|
session.doc.insertLines(1, ["\t\t"]);
|
||||||
|
assert.equal(session.getWidth(), 3);
|
||||||
|
assert.equal(session.getScreenWidth(), 8);
|
||||||
|
|
||||||
|
session.setTabSize(2);
|
||||||
|
assert.equal(session.getWidth(), 3);
|
||||||
|
assert.equal(session.getScreenWidth(), 4);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue