diff options
Diffstat (limited to 'ui/tunnelspage.go')
-rw-r--r-- | ui/tunnelspage.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ui/tunnelspage.go b/ui/tunnelspage.go index bf80107d..33b2c03e 100644 --- a/ui/tunnelspage.go +++ b/ui/tunnelspage.go @@ -394,9 +394,27 @@ func (tp *TunnelsPage) onDelete() { walk.MsgBoxYesNo|walk.MsgBoxIconWarning) { return } + + selectTunnelAfter := "" + if len(indices) < len(tp.tunnelsView.model.tunnels) { + sort.Ints(indices) + max := 0 + for i, idx := range indices { + if idx+1 < len(tp.tunnelsView.model.tunnels) && (i+1 == len(indices) || idx+1 != indices[i+1]) { + max = idx + 1 + } else if idx-1 >= 0 && (i == 0 || idx-1 != indices[i-1]) { + max = idx - 1 + } + } + selectTunnelAfter = tp.tunnelsView.model.tunnels[max].Name + } + for _, i := range indices { tp.deleteTunnel(&tp.tunnelsView.model.tunnels[i]) } + if len(selectTunnelAfter) > 0 { + tp.tunnelsView.selectTunnel(selectTunnelAfter) + } } func (tp *TunnelsPage) onImport() { |