| Ticket UUID: | 34db75c0acee5dcf10e71cedbef78a2b099a5591 | |||
| Title: | Text peer widget error on Down arrow key when passed -endline line | |||
| Type: | Bug | Version: | 8.6.11, revised_text | |
| Submitter: | anonymous | Created on: | 2021-04-10 00:26:54 | |
| Subsystem: | 75. wish | Assigned To: | fvogel | |
| Priority: | 5 Medium | Severity: | Critical | |
| Status: | Closed | Last Modified: | 2024-09-13 21:48:37 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2024-09-13 21:48:37 | |||
| Description: |
To reproduce: package require Tk pack [text .t] .t insert end "line 1\nline 2\nline 3\n" pack [.t peer create .p -startline 1 -endline 2]Click inside the bottom (peer) window and press the Down arrow key to move the insert mark. As soon as it passes the end of the set -endline it gives this error:
bad text index "insert"
while executing
"$w see insert"
(procedure "tk::TextSetCursor" line 7)
invoked from within
"tk::TextSetCursor .p [tk::TextUpDownLine .p 1]"
(command bound to event)
It seems that the line:
if {[$w compare $pos == end]} {
should have a '>=' instead of a '=='. Here is a fix:
proc ::tk::TextSetCursor {w pos} {
if {[$w compare $pos >= end]} {
set pos {end - 1 chars}
}
$w mark set insert $pos
$w tag remove sel 1.0 end
$w see insert
if {[$w cget -autoseparators]} {
$w edit separator
}
}
dzach
| |||
| User Comments: |
fvogel added on 2024-09-13 21:48:37:
For the record I have made a further fix linked to this ticket, see [1871581951]. fvogel added on 2021-04-18 11:51:30: Merged into core-8-6-branch and trunk (branch bug-34db75c0ac for the legacy text widget) and into revised_text as well (branch bug-34db75c0ac_revised_text). fvogel added on 2021-04-18 10:29:41: I have now made a fix for the revised_text widget as well since it didn't pass the new tests (several failed assertions were triggered). See branch bug-34db75c0ac_revised_text. anonymous added on 2021-04-12 19:33:56: @fvogel, thanks for looking into this. I've tried the proposed fix and it appears to have fixed this bug. Both textIndex-26.1 and textMark-6.6 pass successfully. OS is Kubuntu 18.04, CPU is AMD64. dzach fvogel added on 2021-04-11 19:00:30: Thanks for this second bug report. I see that you have posted a separate ticket for this at [ea876b3e8a], which is The Right Thing To Do (TM). Regarding the present ticket, I have proposed a fix that I think is better, see [e7a66e88], along with a new non-regression test [57affc1a]. All text*.test files do pass with this for me on Windows 10. anonymous added on 2021-04-10 13:26:48: A similar problem with the text peer index handling also appears when working with a scroll bar: the peer's 1.0 index (which starts at line 5 of the original) seems to be ignored and instead the original text widget's index seems to apply. Here is how to reproduce it:
package require Tk
pack [text .t -yscrollcommand {.sb set}] -side left
pack [.t peer create .p] -side left
pack [scrollbar .sb -command {.p yview}] -side left -fill y
for {set i 1} {$i < 50} {incr i} {
.t insert end "line $i\n"
}
.p configure -startline 5 -endline 35
Scroll the peer widget up/down using the mouse wheel; text remains within set limits 5 and 35.
Now scroll the peer widget up using the scrollbar; instead of stopping at "line 5" the widget now displays "line 1" at the top. dzach fvogel added on 2021-04-10 09:47:07: I'm wondering if the fix is the right one though. I think the issue rather is the following: % package require Tk 8.6.11 % pack [text .t] % .t insert end "line 1\nline 2\nline 3\n" % pack [.t peer create .p -startline 1 -endline 2] % % .p index end 2.0 % .p index "end display lineend" 2.5 % .p index "end lineend" 2.6 Note that the revised text widget spits "2.0" for the last three commands above, which sounds correct to me. In other words, the code in text.tcl is correct I think, both in tk::TextSetCursor and tk::TextUpDownLine, and the bug could rather be in GetIndex(). fvogel added on 2021-04-10 09:25:59: Non-regression testcase added, see [1c310f76]. This one can/should be propagated to the revised_text branch. fvogel added on 2021-04-10 08:50:24: Thanks for the report and the fix! The proposed fix indeed works, I have put it in a bugfix branch, see [e58d221818]. Note that the revised text widget does not suffer from the same problem and addresses this issue differently. The present fix should not be propagated into the revised_text branch. | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki