Ticket UUID: | 3554273 | |||
Title: | Test textDisp-32.2 (elide and tags) fails | |||
Type: | Bug | Version: | None | |
Submitter: | fvogel | Created on: | 2012-08-04 14:23:20 | |
Subsystem: | 18. [text] | Assigned To: | fvogel | |
Priority: | 7 High | Severity: | Minor | |
Status: | Closed | Last Modified: | 2014-02-19 21:42:33 | |
Resolution: | Fixed | Closed By: | fvogel | |
Closed on: | 2013-09-23 21:43:40 | |||
Description: |
In both core-8-5-branch and trunk: ==== textDisp-32.2 elide and tags FAILED ==== Contents of test case: pack [text .tt -height 30 -width 100 -bd 0 -highlightthickness 0 -padx 0] .tt insert end {test text using tags 1 and 3 } {testtag1 testtag3} {[this bit here uses tags 2 and 3]} {testtag2 testtag3} update # indent left margin of tag 1 by 20 pixels # text should be indented .tt tag configure testtag1 -lmargin1 20 ; update #1 set res {} lappend res [list [.tt index "1.0 + 0 displaychars"] [lindex [.tt bbox 1.0] 0] [lindex [.tt bbox "1.0 + 0 displayc hars"] 0]] # hide tag 1, remaining text should not be indented, since # the indented tag and character is hidden. .tt tag configure testtag1 -elide 1 ; update #2 lappend res [list [.tt index "1.0 + 0 displaychars"] [lindex [.tt bbox 1.0] 0] [lindex [.tt bbox "1.0 + 0 displayc hars"] 0]] # reset .tt tag configure testtag1 -lmargin1 0 .tt tag configure testtag1 -elide 0 # indent left margin of tag 2 by 20 pixels # text should not be indented, since tag1 has lmargin1 of 0. .tt tag configure testtag2 -lmargin1 20 ; update #3 lappend res [list [.tt index "1.0 + 0 displaychars"] [lindex [.tt bbox 1.0] 0] [lindex [.tt bbox "1.0 + 0 displayc hars"] 0]] # hide tag 1, remaining text should now be indented, but # the bbox of 1.0 should have zero width and zero indent, # since it is elided at that position. .tt tag configure testtag1 -elide 1 ; update #4 lappend res [list [.tt index "1.0 + 0 displaychars"] [lindex [.tt bbox 1.0] 0] [lindex [.tt bbox "1.0 + 0 displayc hars"] 0]] # reset .tt tag configure testtag2 -lmargin1 {} .tt tag configure testtag1 -elide 0 # indent left margin of tag 3 by 20 pixels # text should be indented, since this tag takes # precedence over testtag1, and is applied to the # start of the text. .tt tag configure testtag3 -lmargin1 20 ; update #5 lappend res [list [.tt index "1.0 + 0 displaychars"] [lindex [.tt bbox 1.0] 0] [lindex [.tt bbox "1.0 + 0 displayc hars"] 0]] # hide tag 1, remaining text should still be indented, # since it still has testtag3 on it. Again the # bbox of 1.0 should have 0. .tt tag configure testtag1 -elide 1 ; update #6 lappend res [list [.tt index "1.0 + 0 displaychars"] [lindex [.tt bbox 1.0] 0] [lindex [.tt bbox "1.0 + 0 displayc hars"] 0]] .tt tag configure testtag3 -lmargin1 {} -elide 0 .tt tag configure testtag1 -elide 1 -lmargin1 20 #7 lappend res [list [.tt index "1.0 + 0 displaychars"] [lindex [.tt bbox 1.0] 0] [lindex [.tt bbox "1.0 + 0 displayc hars"] 0]] destroy .tt set res ---- Result was: {1.0 20 20} {1.0 0 0} {1.0 0 0} {1.0 0 0} {1.0 20 20} {1.0 0 0} {1.0 20 20} ---- Result should have been (exact matching): {1.0 20 20} {1.29 0 0} {1.0 0 0} {1.29 0 20} {1.0 20 20} {1.29 0 20} {1.0 20 20} ==== textDisp-32.2 FAILED | |||
User Comments: |
fvogelnew1 added on 2012-08-11 14:47:51:
allow_comments - 1 Fix merged in core-8-5-branch and trunk. fvogelnew1 added on 2012-08-04 21:40:53: A trimmed down test case: pack [text .tt -height 30 -width 100 -bd 0 -highlightthickness 0 -padx 0] .tt insert end {test text using tags 1 and 3 } {testtag1 testtag3} .tt insert end {[this bit here uses tags 2 and 3]} {testtag2 testtag3} update set res {} lappend res [.tt index "1.0 + 0 displaychars"] .tt tag configure testtag1 -elide 1 ; update lappend res [.tt index "1.0 + 0 displaychars"] lappend res [.tt index "1.0 + 0 display chars"] #---- Wrong result is: #1.0 1.0 1.29 #---- Correct result is: #1.0 1.29 1.29 destroy .tt Analysis: The indices are calculated when calling the first lappend res [.tt index "1.0 + 0 displaychars"] and then cached by the text widget. When requesting lappend res [.tt index "1.0 + 0 displaychars"] a second time, the cached index is returned (which is wrong). Fix: tag configure -elide should increase the epoch so that indices are recomputed after the elide state of tags is changed. I have proposed that fix in branch bug-3554273 Review welcome. |