Clamp column returned by Document.screenToDocumentPosition

This commit is contained in:
Julian Viereck 2011-01-09 19:46:37 +01:00
commit be957fd2c1

View file

@ -1027,10 +1027,14 @@ var Document = function(text, mode) {
row -= wrapData[docRow].length + 1; row -= wrapData[docRow].length + 1;
docRow ++; docRow ++;
} }
var docColumn = column + var docColumn = column +
(docRow < linesCount ? wrapData[docRow][row - 1] || 0 : 0); (docRow < linesCount ? wrapData[docRow][row - 1] || 0 : 0);
if (this.lines[docRow]) { // Clamp docColumn.
if (docRow < linesCount && wrapData[docRow][row]) {
docColumn = Math.min(docColumn, wrapData[docRow][row]);
} else if (this.lines[docRow]) {
docColumn = Math.min(docColumn, this.lines[docRow].length); docColumn = Math.min(docColumn, this.lines[docRow].length);
} }