fix clipping at the boundaries, and add more tests
This commit is contained in:
parent
ac324e8fb0
commit
e2d47c6a60
2 changed files with 14 additions and 6 deletions
|
|
@ -1386,9 +1386,7 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
var doCache = !rowCache.length || i == rowCache.length;
|
var doCache = !rowCache.length || i == rowCache.length;
|
||||||
|
|
||||||
// clamp row before clamping column, for selection on last line
|
|
||||||
var maxRow = this.getLength() - 1;
|
var maxRow = this.getLength() - 1;
|
||||||
|
|
||||||
var foldLine = this.getNextFoldLine(docRow);
|
var foldLine = this.getNextFoldLine(docRow);
|
||||||
var foldStart = foldLine ? foldLine.start.row : Infinity;
|
var foldStart = foldLine ? foldLine.start.row : Infinity;
|
||||||
|
|
||||||
|
|
@ -1416,6 +1414,12 @@ var EditSession = function(text, mode) {
|
||||||
if (foldLine && foldLine.start.row <= docRow) {
|
if (foldLine && foldLine.start.row <= docRow) {
|
||||||
line = this.getFoldDisplayLine(foldLine);
|
line = this.getFoldDisplayLine(foldLine);
|
||||||
docRow = foldLine.start.row;
|
docRow = foldLine.start.row;
|
||||||
|
} else if (row + rowLength <= screenRow || docRow > maxRow) {
|
||||||
|
// clip at the end of the document
|
||||||
|
return {
|
||||||
|
row: maxRow,
|
||||||
|
column: this.getLine(maxRow).length
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
line = this.getLine(docRow);
|
line = this.getLine(docRow);
|
||||||
foldLine = null;
|
foldLine = null;
|
||||||
|
|
@ -1434,10 +1438,6 @@ var EditSession = function(text, mode) {
|
||||||
|
|
||||||
docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
|
docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
|
||||||
|
|
||||||
// clip row at the end of the document
|
|
||||||
if (docRow > maxRow)
|
|
||||||
docColumn = Number.MAX_VALUE;
|
|
||||||
|
|
||||||
// Need to do some clamping action here.
|
// Need to do some clamping action here.
|
||||||
if (this.$useWrapMode) {
|
if (this.$useWrapMode) {
|
||||||
if (docColumn >= column) {
|
if (docColumn >= column) {
|
||||||
|
|
|
||||||
|
|
@ -363,6 +363,14 @@ module.exports = {
|
||||||
assert.position(session.screenToDocumentPosition(1, 30), 1, 12);
|
assert.position(session.screenToDocumentPosition(1, 30), 1, 12);
|
||||||
assert.position(session.screenToDocumentPosition(20, 50), 1, 12);
|
assert.position(session.screenToDocumentPosition(20, 50), 1, 12);
|
||||||
assert.position(session.screenToDocumentPosition(20, 5), 1, 12);
|
assert.position(session.screenToDocumentPosition(20, 5), 1, 12);
|
||||||
|
|
||||||
|
// and the same for folded rows
|
||||||
|
session.addFold("...", new Range(0,1,1,3));
|
||||||
|
assert.position(session.screenToDocumentPosition(1, 2), 1, 12);
|
||||||
|
// for wrapped rows
|
||||||
|
session.setUseWrapMode(true);
|
||||||
|
session.setWrapLimitRange(5,5);
|
||||||
|
assert.position(session.screenToDocumentPosition(4, 1), 1, 12);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: wrapLine split function" : function() {
|
"test: wrapLine split function" : function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue