Skip to content

Commit b28ebab

Browse files
angavrilovspearce
authored andcommitted
git-gui: Fix focus transition in the blame viewer.
Now that the blame viewer has a search panel, it should be taken into account by the focus transition code. Otherwise showing a commit tip (by accidentally moving the mouse to the text frame) causes the focus to transfer away from the search field. Signed-off-by: Alexander Gavrilov <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 9d83c6a commit b28ebab

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

lib/blame.tcl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ constructor new {i_commit i_path i_jump} {
321321
tk_popup $w.ctxm %X %Y
322322
"
323323
bind $i <Shift-Tab> "[list focus $w_cviewer];break"
324-
bind $i <Tab> "[list focus $w_cviewer];break"
324+
bind $i <Tab> "[cb _focus_search $w_cviewer];break"
325325
}
326326

327327
foreach i [concat $w_columns $w_cviewer] {
@@ -337,10 +337,10 @@ constructor new {i_commit i_path i_jump} {
337337
bind $i <Control-Key-f> {catch {%W yview scroll 1 pages};break}
338338
}
339339

340-
bind $w_cviewer <Shift-Tab> "[list focus $w_file];break"
340+
bind $w_cviewer <Shift-Tab> "[cb _focus_search $w_file];break"
341341
bind $w_cviewer <Tab> "[list focus $w_file];break"
342-
bind $w_cviewer <Button-1> [list focus $w_cviewer]
343-
bind $w_file <Visibility> [list focus $w_file]
342+
bind $w_cviewer <Button-1> [list focus $w_cviewer]
343+
bind $w_file <Visibility> [cb _focus_search $w_file]
344344
bind $top <F7> [list searchbar::show $finder]
345345
bind $top <Escape> [list searchbar::hide $finder]
346346
bind $top <F3> [list searchbar::find_next $finder]
@@ -382,6 +382,14 @@ constructor new {i_commit i_path i_jump} {
382382
_load $this $i_jump
383383
}
384384

385+
method _focus_search {win} {
386+
if {[searchbar::visible $finder]} {
387+
focus [searchbar::editor $finder]
388+
} else {
389+
focus $win
390+
}
391+
}
392+
385393
method _handle_destroy {win} {
386394
if {$win eq $w} {
387395
_kill $this

lib/search.tcl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ constructor new {i_w i_text args} {
1919

2020
frame $w
2121
label $w.l -text [mc Find:]
22+
entry $w.ent -textvariable ${__this}::searchstring -background lightgreen
2223
button $w.bn -text [mc Next] -command [cb find_next]
2324
button $w.bp -text [mc Prev] -command [cb find_prev]
2425
checkbutton $w.cs -text [mc Case-Sensitive] \
2526
-variable ${__this}::casesensitive -command [cb _incrsearch]
26-
entry $w.ent -textvariable ${__this}::searchstring -background lightgreen
2727
pack $w.l -side left
2828
pack $w.cs -side right
2929
pack $w.bp -side right
@@ -40,19 +40,27 @@ constructor new {i_w i_text args} {
4040
}
4141

4242
method show {} {
43-
if {![winfo ismapped $w]} {
43+
if {![visible $this]} {
4444
grid $w
4545
}
4646
focus -force $w.ent
4747
}
4848

4949
method hide {} {
50-
if {[winfo ismapped $w]} {
50+
if {[visible $this]} {
5151
focus $ctext
5252
grid remove $w
5353
}
5454
}
5555

56+
method visible {} {
57+
return [winfo ismapped $w]
58+
}
59+
60+
method editor {} {
61+
return $w.ent
62+
}
63+
5664
method _get_new_anchor {} {
5765
# use start of selection if it is visible,
5866
# or the bounds of the visible area

0 commit comments

Comments
 (0)