@@ -2361,6 +2361,7 @@ proc makewindow {} {
2361
2361
$ctext tag conf mresult -font textfontbold
2362
2362
$ctext tag conf msep -font textfontbold
2363
2363
$ctext tag conf found -back yellow
2364
+ $ctext tag conf currentsearchhit -back orange
2364
2365
2365
2366
.pwbottom add .bleft
2366
2367
if {!$use_ttk } {
@@ -2523,6 +2524,7 @@ proc makewindow {} {
2523
2524
bind $cflist $ctxbut {pop_flist_menu %W %X %Y %x %y}
2524
2525
bind $ctext $ctxbut {pop_diff_menu %W %X %Y %x %y}
2525
2526
bind $ctext <Button-1> {focus %W}
2527
+ bind $ctext <<Selection>> rehighlight_search_results
2526
2528
2527
2529
set maincursor [. cget -cursor]
2528
2530
set textcursor [$ctext cget -cursor]
@@ -8039,7 +8041,6 @@ proc settabs {{firstab {}}} {
8039
8041
proc incrsearch {name ix op} {
8040
8042
global ctext searchstring searchdirn
8041
8043
8042
- $ctext tag remove found 1.0 end
8043
8044
if {[catch {$ctext index anchor}]} {
8044
8045
# no anchor set, use start of selection, or of visible area
8045
8046
set sel [$ctext tag ranges sel]
@@ -8058,8 +8059,8 @@ proc incrsearch {name ix op} {
8058
8059
suppress_highlighting_file_for_current_scrollpos
8059
8060
highlightfile_for_scrollpos $here
8060
8061
}
8061
- searchmarkvisible 1
8062
8062
}
8063
+ rehighlight_search_results
8063
8064
}
8064
8065
8065
8066
proc dosearch {} {
@@ -8087,6 +8088,7 @@ proc dosearch {} {
8087
8088
set mend " $match + $mlen c"
8088
8089
$ctext tag add sel $match $mend
8089
8090
$ctext mark unset anchor
8091
+ rehighlight_search_results
8090
8092
}
8091
8093
}
8092
8094
@@ -8115,18 +8117,36 @@ proc dosearchback {} {
8115
8117
set mend " $match + $ml c"
8116
8118
$ctext tag add sel $match $mend
8117
8119
$ctext mark unset anchor
8120
+ rehighlight_search_results
8121
+ }
8122
+ }
8123
+
8124
+ proc rehighlight_search_results {} {
8125
+ global ctext searchstring
8126
+
8127
+ $ctext tag remove found 1.0 end
8128
+ $ctext tag remove currentsearchhit 1.0 end
8129
+
8130
+ if {$searchstring ne {}} {
8131
+ searchmarkvisible 1
8118
8132
}
8119
8133
}
8120
8134
8121
8135
proc searchmark {first last} {
8122
8136
global ctext searchstring
8123
8137
8138
+ set sel [$ctext tag ranges sel]
8139
+
8124
8140
set mend $first .0
8125
8141
while {1} {
8126
8142
set match [$ctext search -count mlen -- $searchstring $mend $last .end]
8127
8143
if {$match eq {}} break
8128
8144
set mend " $match + $mlen c"
8129
- $ctext tag add found $match $mend
8145
+ if {$sel ne {} && [$ctext compare $match == [lindex $sel 0]]} {
8146
+ $ctext tag add currentsearchhit $match $mend
8147
+ } else {
8148
+ $ctext tag add found $match $mend
8149
+ }
8130
8150
}
8131
8151
}
8132
8152
0 commit comments