From 683752762d5d124d4b428b21f1a24bdfbc7566f2 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Wed, 3 Oct 2012 08:03:51 +0100 Subject: [PATCH] Fix to 1st line charCount & simplifying endPos.ch If our result is within the first line, add 1 to it to fix offset No need to have ternary case for replace all, this is now done with a regex --- lib/coder.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/coder.js b/lib/coder.js index f5323ff..a67d06b 100644 --- a/lib/coder.js +++ b/lib/coder.js @@ -958,14 +958,15 @@ var ICEcoder = { } charCount = ICEcoder.results[ICEcoder.findResult] - numChars - 1; + if (ICEcoder.results[ICEcoder.findResult]<=cM.lineInfo(0).text.length) { + charCount++; + } startPos = new Object(); startPos.line = lineCount; startPos.ch = charCount; endPos = new Object(); endPos.line = lineCount; - document.findAndReplace.connector.value=="and" && document.findAndReplace.replaceAction.value=="replace all" && buttonClick - ? endPos.ch = charCount+replaceLen - : endPos.ch = charCount+findLen; + endPos.ch = charCount+findLen; // Finally, highlight our selection cM = ICEcoder.getcMInstance(); cM.setSelection(startPos, endPos);