From be957fd2c1c27c4c8bc062cabedab9263fc5bdbd Mon Sep 17 00:00:00 2001 From: Julian Viereck Date: Sun, 9 Jan 2011 19:46:37 +0100 Subject: [PATCH] Clamp column returned by Document.screenToDocumentPosition --- lib/ace/document.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); }