Fix calculation of EditSession.getScreenLength.
This commit is contained in:
parent
56619e516b
commit
55e0f8ceff
2 changed files with 24 additions and 14 deletions
|
|
@ -155,6 +155,8 @@ exports.launch = function(env) {
|
|||
var container = document.getElementById("editor");
|
||||
var cockpitInput = document.getElementById("cockpitInput");
|
||||
env.editor = new Editor(new Renderer(container, theme));
|
||||
window.env = env;
|
||||
window.ace = env.editor;
|
||||
|
||||
var modes = {
|
||||
text: new TextMode(),
|
||||
|
|
|
|||
|
|
@ -1596,21 +1596,29 @@ var EditSession = function(text, mode) {
|
|||
};
|
||||
|
||||
this.getScreenLength = function() {
|
||||
var length = this.getLength();
|
||||
var screenRows = 0;
|
||||
var lastFoldLine = null;
|
||||
var foldLine = null;
|
||||
if (!this.$useWrapMode) {
|
||||
screenRows = length;
|
||||
screenRows = this.getLength();
|
||||
|
||||
// Remove the folded lines again.
|
||||
var foldData = this.$foldData;
|
||||
for (var i = 0; i < foldData.length; i++) {
|
||||
foldLine = foldData[i];
|
||||
screenRows -= foldLine.end.row - foldLine.start.row;
|
||||
}
|
||||
} else {
|
||||
for (var row = 0; row < this.$wrapData.length; row++) {
|
||||
screenRows += this.$wrapData[row].length + 1;
|
||||
if (foldLine = this.getFoldLine(row, lastFoldLine)) {
|
||||
row = foldLine.end.row;
|
||||
screenRows += 1;
|
||||
} else {
|
||||
screenRows += this.$wrapData[row].length + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var foldData = this.$foldData;
|
||||
for (var i = 0; i < foldData.length; i++) {
|
||||
var foldLine = foldData[i];
|
||||
screenRows -= foldLine.end.row - foldLine.start.row;
|
||||
}
|
||||
return screenRows;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue