From a1993bc0745db8b904bd8c851b2f410ca0cd42d0 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Mon, 20 May 2013 18:47:25 +0300 Subject: [PATCH] [feature/editor-code-tabs] Correctly calculate end tag location PHPBB3-11557 --- phpBB/styles/prosilver/template/editor.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/editor.js b/phpBB/styles/prosilver/template/editor.js index 9ec8409560..4975c8e5a0 100644 --- a/phpBB/styles/prosilver/template/editor.js +++ b/phpBB/styles/prosilver/template/editor.js @@ -441,9 +441,12 @@ function getCaretPosition(txtarea) { } if (lastStart == -1) return false; - for (i = 0; i < endTags.length; i++) { - index = value.lastIndexOf(endTags[i], start); - lastEnd = Math.max(lastEnd, index); + if (start > 0) + { + for (i = 0; i < endTags.length; i++) { + index = value.lastIndexOf(endTags[i], start - 1); + lastEnd = Math.max(lastEnd, index); + } } return (lastEnd < lastStart);