From 030aca39c08ef652e36870abdeee1bc2f2566e28 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 6 Oct 2015 22:47:31 +0000 Subject: Added test for bug [2262711fff] - Regexp search fails with Unicode and elide --- tests/text.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/text.test b/tests/text.test index fa00ce3..ee75a6c 100644 --- a/tests/text.test +++ b/tests/text.test @@ -2781,6 +2781,24 @@ test text-20.185 {TextSearchCmd, elide up to match} { lappend res [.t2 search -regexp bc 1.0] lappend res [.t2 search -regexp c 1.0] } {{} {} 1.0 2.1 2.0 3.1 2.0 3.0} +test text-20.185.1 {TextSearchCmd, elide up to match, with UTF-8 chars before the match} { + deleteWindows + pack [text .t2] + .t2 tag configure e -elide 0 + .t2 insert end A {} xyz e bb\n + .t2 insert end \u00c4 {} xyz e bb + set res {} + lappend res [.t2 search bb 1.0 "1.0 lineend"] + lappend res [.t2 search bb 2.0 "2.0 lineend"] + lappend res [.t2 search -regexp bb 1.0 "1.0 lineend"] + lappend res [.t2 search -regexp bb 2.0 "2.0 lineend"] + .t2 tag configure e -elide 1 + lappend res [.t2 search bb 1.0 "1.0 lineend"] + lappend res [.t2 search bb 2.0 "2.0 lineend"] + lappend res [.t2 search -regexp bb 1.0 "1.0 lineend"] + lappend res [.t2 search -regexp -elide bb 2.0 "2.0 lineend"] + lappend res [.t2 search -regexp bb 2.0 "2.0 lineend"] +} {1.4 2.4 1.4 2.4 1.4 2.4 1.4 2.4 2.4} test text-20.186 {TextSearchCmd, strict limits} { deleteWindows pack [text .t2] -- cgit v0.12 From 687cdd2ef3948e5acf8a888de2578fa194958bcf Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 6 Oct 2015 22:50:36 +0000 Subject: Fixed bug [2262711fff] - Regexp search fails with Unicode and elide --- generic/tkText.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/generic/tkText.c b/generic/tkText.c index f023509..cb89218 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -4196,7 +4196,11 @@ TextSearchFoundMatch( matchOffset += Tcl_NumUtfChars(segPtr->body.chars, -1); } } else { - leftToScan -= segPtr->size; + if (searchSpecPtr->exact) { + leftToScan -= segPtr->size; + } else { + leftToScan -= Tcl_NumUtfChars(segPtr->body.chars, -1); + } } curIndex.byteIndex += segPtr->size; } -- cgit v0.12