diff options
Diffstat (limited to 'library')
-rw-r--r-- | library/tearoff.tcl | 8 | ||||
-rw-r--r-- | library/text.tcl | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/library/tearoff.tcl b/library/tearoff.tcl index b500023..c2d2d6b 100644 --- a/library/tearoff.tcl +++ b/library/tearoff.tcl @@ -154,7 +154,9 @@ proc ::tk::MenuDup {src dst type} { # Copy tags to x, replacing each substring of src with dst. while {[set index [string first $src $tags]] != -1} { - append x [string range $tags 0 [expr {$index - 1}]]$dst + if {$index > 0} { + append x [string range $tags 0 [expr {$index - 1}]]$dst + } set tags [string range $tags [expr {$index + $srcLen}] end] } append x $tags @@ -169,7 +171,9 @@ proc ::tk::MenuDup {src dst type} { # Copy script to x, replacing each substring of event with dst. while {[set index [string first $event $script]] != -1} { - append x [string range $script 0 [expr {$index - 1}]] + if {$index > 0} { + append x [string range $script 0 [expr {$index - 1}]] + } append x $dst set script [string range $script [expr {$index + $eventLen}] end] } diff --git a/library/text.tcl b/library/text.tcl index 62db560..6d3df8e 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -1278,7 +1278,11 @@ proc ::tk::TextUndoRedoProcessMarks {w} { set nUndoMarks [llength $undoMarks] set n [expr {$nUndoMarks / 2}] set undoMarks [lsort -dictionary $undoMarks] - set Lmarks [lrange $undoMarks 0 [expr {$n - 1}]] + if {$n > 0} { + set Lmarks [lrange $undoMarks 0 [expr {$n - 1}]] + } else { + set Lmarks {} + } set Rmarks [lrange $undoMarks $n [llength $undoMarks]] foreach Lmark $Lmarks Rmark $Rmarks { lappend indices [$w index $Lmark] [$w index $Rmark] |