fix: resolve omnibox lint regressions
Refactor small sections of omnibox keyboard handling and selection target assignment to satisfy golangci-lint funlen and staticcheck rules without changing runtime behavior.
- commit
- 25ff751509b844d9af709813591a0c79942dce5e
- author
- brice · · 2026-02-17 17:47 UTC
- parent
- a5f78e3
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +9 -9
M internal/ui/component/omnibox.go +9 -9
| @@ -578,8 +578,7 @@ func (o *Omnibox) initList() error { | |||
| 578 | 578 | return | |
| 579 | 579 | } | |
| 580 | 580 | ||
| 581 | - | var targetURL string | |
| 582 | - | targetURL = resolveTargetURLForSelection(mode, idx, suggestions, favorites) | |
| 581 | + | targetURL := resolveTargetURLForSelection(mode, idx, suggestions, favorites) | |
| 583 | 582 | ||
| 584 | 583 | if targetURL != "" && o.onNavigate != nil { | |
| 585 | 584 | o.Hide(o.ctx) | |
| @@ -674,9 +673,7 @@ func (o *Omnibox) hasUserNavigated() bool { | |||
| 674 | 673 | // handleKeyPress processes keyboard events. | |
| 675 | 674 | // Returns true if the event was handled. | |
| 676 | 675 | func (o *Omnibox) handleKeyPress(keyval, keycode uint, state gdk.ModifierType) bool { | |
| 677 | - | o.mu.Lock() | |
| 678 | - | o.suppressGhost = nextGhostSuppressionState(o.suppressGhost, keyval) | |
| 679 | - | o.mu.Unlock() | |
| 676 | + | o.updateGhostSuppressionFromKey(keyval) | |
| 680 | 677 | ||
| 681 | 678 | ctrl := state&gdk.ControlMaskValue != 0 | |
| 682 | 679 | ||
| @@ -752,10 +749,13 @@ func (o *Omnibox) handleKeyPress(keyval, keycode uint, state gdk.ModifierType) b | |||
| 752 | 749 | } | |
| 753 | 750 | ||
| 754 | 751 | func nextGhostSuppressionState(_ bool, keyval uint) bool { | |
| 755 | - | if isDeletionKey(keyval) { | |
| 756 | - | return true | |
| 757 | - | } | |
| 758 | - | return false | |
| 752 | + | return isDeletionKey(keyval) | |
| 753 | + | } | |
| 754 | + | ||
| 755 | + | func (o *Omnibox) updateGhostSuppressionFromKey(keyval uint) { | |
| 756 | + | o.mu.Lock() | |
| 757 | + | o.suppressGhost = nextGhostSuppressionState(o.suppressGhost, keyval) | |
| 758 | + | o.mu.Unlock() | |
| 759 | 759 | } | |
| 760 | 760 | ||
| 761 | 761 | func isDeletionKey(keyval uint) bool { | |
| @@ -578,8 +578,7 @@ func (o *Omnibox) initList() error { | |||||
| 578 | return | 578 | return | ||
| 579 | } | 579 | } | ||
| 580 | 580 | ||||
| 581 | - | var targetURL string | 581 | + | targetURL := resolveTargetURLForSelection(mode, idx, suggestions, favorites) |
| 582 | - | targetURL = resolveTargetURLForSelection(mode, idx, suggestions, favorites) | |||
| 583 | 582 | ||||
| 584 | if targetURL != "" && o.onNavigate != nil { | 583 | if targetURL != "" && o.onNavigate != nil { | ||
| 585 | o.Hide(o.ctx) | 584 | o.Hide(o.ctx) | ||
| @@ -674,9 +673,7 @@ func (o *Omnibox) hasUserNavigated() bool { | |||||
| 674 | // handleKeyPress processes keyboard events. | 673 | // handleKeyPress processes keyboard events. | ||
| 675 | // Returns true if the event was handled. | 674 | // Returns true if the event was handled. | ||
| 676 | func (o *Omnibox) handleKeyPress(keyval, keycode uint, state gdk.ModifierType) bool { | 675 | func (o *Omnibox) handleKeyPress(keyval, keycode uint, state gdk.ModifierType) bool { | ||
| 677 | - | o.mu.Lock() | 676 | + | o.updateGhostSuppressionFromKey(keyval) |
| 678 | - | o.suppressGhost = nextGhostSuppressionState(o.suppressGhost, keyval) | |||
| 679 | - | o.mu.Unlock() | |||
| 680 | 677 | ||||
| 681 | ctrl := state&gdk.ControlMaskValue != 0 | 678 | ctrl := state&gdk.ControlMaskValue != 0 | ||
| 682 | 679 | ||||
| @@ -752,10 +749,13 @@ func (o *Omnibox) handleKeyPress(keyval, keycode uint, state gdk.ModifierType) b | |||||
| 752 | } | 749 | } | ||
| 753 | 750 | ||||
| 754 | func nextGhostSuppressionState(_ bool, keyval uint) bool { | 751 | func nextGhostSuppressionState(_ bool, keyval uint) bool { | ||
| 755 | - | if isDeletionKey(keyval) { | 752 | + | return isDeletionKey(keyval) |
| 756 | - | return true | 753 | + | } |
| 757 | - | } | 754 | + | |
| 758 | - | return false | 755 | + | func (o *Omnibox) updateGhostSuppressionFromKey(keyval uint) { |
| 756 | + | o.mu.Lock() | |||
| 757 | + | o.suppressGhost = nextGhostSuppressionState(o.suppressGhost, keyval) | |||
| 758 | + | o.mu.Unlock() | |||
| 759 | } | 759 | } | ||
| 760 | 760 | ||||
| 761 | func isDeletionKey(keyval uint) bool { | 761 | func isDeletionKey(keyval uint) bool { | ||