From 9cd16d73c3ffe93977a7fba71483ca56869cdb88 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 22 Sep 2017 20:25:38 +0000 Subject: Fix [dd9667635d]: text anchor not set --- library/text.tcl | 3 +++ tests/text.test | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/library/text.tcl b/library/text.tcl index 9eb6e31..645776d 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -768,6 +768,9 @@ proc ::tk::TextKeySelect {w new} { } $w mark set $anchorname insert } else { + if {[catch {$w index $anchorname}]} { + $w mark set $anchorname insert + } if {[$w compare $new < $anchorname]} { set first $new set last $anchorname diff --git a/tests/text.test b/tests/text.test index 42b6114..6b4a597 100644 --- a/tests/text.test +++ b/tests/text.test @@ -7305,7 +7305,22 @@ test text-35.3 {widget dump -command destroys widget} -setup { } -result {ok} -test text-36.1 "bug #1777362: event handling with hyphenated windows" -setup { +test text-36.1 "bug #dd9667635d: text anchor not set" -setup { + destroy .t + pack [text .t] +} -body { + .t insert end "Hello world!" + .t tag add sel 1.0 end + # this line shall not trigger error: + # bad text index "tk::anchor1" + event generate .t <> + update +} -cleanup { + destroy .t +} -result {} + + +test text-37.1 "bug #1777362: event handling with hyphenated windows" -setup { proc bgerror {m} {set ::my_error $m} set ::my_error {} pack [set w [text .t-1]] @@ -7318,7 +7333,7 @@ test text-36.1 "bug #1777362: event handling with hyphenated windows" -setup { } -cleanup { destroy .t-1 } -result {} -test text-36.2 "bug #1777362: event handling with hyphenated windows" -setup { +test text-37.2 "bug #1777362: event handling with hyphenated windows" -setup { proc bgerror {m} {set ::my_error $m} set ::my_error {} pack [set w [text .t+1]] @@ -7331,7 +7346,7 @@ test text-36.2 "bug #1777362: event handling with hyphenated windows" -setup { } -cleanup { destroy $w } -result {} -test text-36.3 "bug #1777362: event handling with hyphenated windows" -setup { +test text-37.3 "bug #1777362: event handling with hyphenated windows" -setup { proc bgerror {m} {set ::my_error $m} set ::my_error {} pack [set w [text .t*1]] -- cgit v0.12