summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2015-10-09 19:28:10 (GMT)
committerfvogel <fvogelnew1@free.fr>2015-10-09 19:28:10 (GMT)
commit4d2b0d587fba77e10b06b3353f3c4a07eabde390 (patch)
tree05391ab62b76a2bd1fc3c2912a5f319b2564fdda
parent1ae4153f65c8bb705a1216a65bc06ab63b3458e6 (diff)
parentbefbed0e52d43e9fe81b8b577dd2dcf7ee01af03 (diff)
downloadtk-4d2b0d587fba77e10b06b3353f3c4a07eabde390.zip
tk-4d2b0d587fba77e10b06b3353f3c4a07eabde390.tar.gz
tk-4d2b0d587fba77e10b06b3353f3c4a07eabde390.tar.bz2
Fixed bug [2262711fff] - Regexp search fails with Unicode and elide
-rw-r--r--generic/tkText.c6
-rw-r--r--tests/text.test21
2 files changed, 26 insertions, 1 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index d93d8fc..b002068 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -4234,7 +4234,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;
}
diff --git a/tests/text.test b/tests/text.test
index 2112aad..95fd4b2 100644
--- a/tests/text.test
+++ b/tests/text.test
@@ -5557,6 +5557,27 @@ test text-22.217 {TextSearchCmd, elide up to match} -setup {
} -cleanup {
destroy .t
} -result {{} {} 1.0 2.1 2.0 3.1 2.0 3.0}
+test text-22.217.1 {elide up to match, with UTF-8 chars before the match} -setup {
+ pack [text .t]
+ set res {}
+} -body {
+ .t tag configure e -elide 0
+ .t insert end A {} xyz e bb\n
+ .t insert end \u00c4 {} xyz e bb
+ set res {}
+ lappend res [.t search bb 1.0 "1.0 lineend"]
+ lappend res [.t search bb 2.0 "2.0 lineend"]
+ lappend res [.t search -regexp bb 1.0 "1.0 lineend"]
+ lappend res [.t search -regexp bb 2.0 "2.0 lineend"]
+ .t tag configure e -elide 1
+ lappend res [.t search bb 1.0 "1.0 lineend"]
+ lappend res [.t search bb 2.0 "2.0 lineend"]
+ lappend res [.t search -regexp bb 1.0 "1.0 lineend"]
+ lappend res [.t search -regexp -elide bb 2.0 "2.0 lineend"]
+ lappend res [.t search -regexp bb 2.0 "2.0 lineend"]
+} -cleanup {
+ destroy .t
+} -result {1.4 2.4 1.4 2.4 1.4 2.4 1.4 2.4 2.4}
test text-22.218 {TextSearchCmd, strict limits} -body {
pack [text .t]
.t insert 1.0 "Hello world!\nThis is a test\n"