Tk Source Code

View Ticket
Login
Ticket UUID: 2262711
Title: Regexp search fails with Unicode and elide
Type: Bug Version: obsolete: 8.5.5
Submitter: kaitzschu Created on: 2008-11-11 14:32:12
Subsystem: 18. [text] Assigned To: fvogel
Priority: 6 Severity: Minor
Status: Closed Last Modified: 2015-10-09 19:29:32
Resolution: Fixed Closed By: fvogel
    Closed on: 2015-10-09 19:29:32
Description:
If searched text is preceded by elided text which is preceded by "above ASCII" character then regexp search fails to count elided characters. Attached code shows this as last [puts] shows index "2.1" instead of "2.4" that is expected.

Confirmed on Tcl/Tk 8.5.5 Linux 2.6.26.6 Gnome 2.22.3. Similar (yet unconfirmed) behavior seen on Windows with 8.5.4.
User Comments: fvogel added on 2015-10-09 19:29:32:
Merged to core-8-5-branch and trunk. Closing.

fvogel added on 2015-10-06 22:53:15:
Proposed fix pushed in branch bug-2262711fff.

fvogel added on 2015-10-06 21:55:16:

I think that the fix [ce92a068] for bug [1174269] did not completely, or fully correctly, address the class of problems reported in [1174269].

Specifically, the adjustment of matchOffset in TextSearchFoundMatch does not look correct to me if text segments before the match contain UTF-8 characters.


fvogel added on 2015-10-06 19:49:08:
Confirmed with the test case provided:

package require Tk
pack [text .t]
.t tag configure e -elide 0
.t insert end A {} xyz e bb\n
.t insert end \u00c4 {} xyz e bb
puts [.t search bb 1.0 "1.0 lineend"]           ; # 1.4   (OK)
puts [.t search bb 2.0 "2.0 lineend"]           ; # 2.4   (OK)
puts [.t search -regexp bb 1.0 "1.0 lineend"]   ; # 1.4   (OK)
puts [.t search -regexp bb 2.0 "2.0 lineend"]   ; # 2.4   (OK)
.t tag configure e -elide 1
puts [.t search bb 1.0 "1.0 lineend"]           ; # 1.4   (OK)
puts [.t search bb 2.0 "2.0 lineend"]           ; # 2.4   (OK)
puts [.t search -regexp bb 1.0 "1.0 lineend"]   ; # 1.4   (OK)
puts [.t search -regexp bb 2.0 "2.0 lineend"]   ; # 2.1   (Arghhh, WRONG!!!)


Interestingly there is apparently no issue when the match does not start just after the elided text.

package require Tk
pack [text .t]
.t tag configure e -elide 0
.t insert end A {} xyz e abb\n
.t insert end \u00c4 {} xyz e abb
puts [.t search bb 1.0 "1.0 lineend"]           
puts [.t search bb 2.0 "2.0 lineend"]           
puts [.t search -regexp bb 1.0 "1.0 lineend"]   
puts [.t search -regexp bb 2.0 "2.0 lineend"]   
.t tag configure e -elide 1
puts [.t search bb 1.0 "1.0 lineend"]           
puts [.t search bb 2.0 "2.0 lineend"]           
puts [.t search -regexp bb 1.0 "1.0 lineend"]   
puts [.t search -regexp bb 2.0 "2.0 lineend"]   

All the output is OK (1.5, 2.5, 1.5, 2.5, 1.5, 2.5, 1.5, 2.5) in this case.

Also, when providing the -elide switch to the last line in the original test case, the output is OK.

kaitzschu added on 2008-11-11 21:32:12:

File Added - 300996: unicodeandelide.tk

Attachments: