diff --git a/lib/ace/document.js b/lib/ace/document.js index a0bc4a5f..488f690a 100644 --- a/lib/ace/document.js +++ b/lib/ace/document.js @@ -1027,10 +1027,14 @@ var Document = function(text, mode) { row -= wrapData[docRow].length + 1; docRow ++; } + var docColumn = column + (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); }