fix(omnibox): log applied top margin and tighten result limit tests
- commit
- 293ffa33635de40597d4ac6d61ec387c86eb39fb
- author
- brice · · 2026-10-10 01:07 UTC
- parent
- 36bf68a
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +5 -5
M internal/ui/component/omnibox.go +3 -3
| @@ -2814,6 +2814,9 @@ func (o *Omnibox) Show(ctx context.Context, query string) { | |||
| 2814 | 2814 | parentHeight = o.parentOverlay.GetAllocatedHeight() | |
| 2815 | 2815 | } | |
| 2816 | 2816 | width, marginTop := o.requestedDimensions() | |
| 2817 | + | if omniboxValign(o.sizeCfg) == gtk.AlignCenterValue { | |
| 2818 | + | marginTop = 0 // centered by GTK; a margin would push it off-center | |
| 2819 | + | } | |
| 2817 | 2820 | log.Debug(). | |
| 2818 | 2821 | Int("parentWidth", parentWidth). | |
| 2819 | 2822 | Int("parentHeight", parentHeight). | |
| @@ -2827,9 +2830,6 @@ func (o *Omnibox) Show(ctx context.Context, query string) { | |||
| 2827 | 2830 | Msg("omnibox geometry decision") | |
| 2828 | 2831 | ||
| 2829 | 2832 | o.mainBox.SetSizeRequest(width, -1) | |
| 2830 | - | if omniboxValign(o.sizeCfg) == gtk.AlignCenterValue { | |
| 2831 | - | marginTop = 0 // centered by GTK; a margin would push it off-center | |
| 2832 | - | } | |
| 2833 | 2833 | o.outerBox.SetMarginTop(marginTop) | |
| 2834 | 2834 | ||
| 2835 | 2835 | // Show the omnibox | |
| @@ -2814,6 +2814,9 @@ func (o *Omnibox) Show(ctx context.Context, query string) { | |||||
| 2814 | parentHeight = o.parentOverlay.GetAllocatedHeight() | 2814 | parentHeight = o.parentOverlay.GetAllocatedHeight() | ||
| 2815 | } | 2815 | } | ||
| 2816 | width, marginTop := o.requestedDimensions() | 2816 | width, marginTop := o.requestedDimensions() | ||
| 2817 | + | if omniboxValign(o.sizeCfg) == gtk.AlignCenterValue { | |||
| 2818 | + | marginTop = 0 // centered by GTK; a margin would push it off-center | |||
| 2819 | + | } | |||
| 2817 | log.Debug(). | 2820 | log.Debug(). | ||
| 2818 | Int("parentWidth", parentWidth). | 2821 | Int("parentWidth", parentWidth). | ||
| 2819 | Int("parentHeight", parentHeight). | 2822 | Int("parentHeight", parentHeight). | ||
| @@ -2827,9 +2830,6 @@ func (o *Omnibox) Show(ctx context.Context, query string) { | |||||
| 2827 | Msg("omnibox geometry decision") | 2830 | Msg("omnibox geometry decision") | ||
| 2828 | 2831 | ||||
| 2829 | o.mainBox.SetSizeRequest(width, -1) | 2832 | o.mainBox.SetSizeRequest(width, -1) | ||
| 2830 | - | if omniboxValign(o.sizeCfg) == gtk.AlignCenterValue { | |||
| 2831 | - | marginTop = 0 // centered by GTK; a margin would push it off-center | |||
| 2832 | - | } | |||
| 2833 | o.outerBox.SetMarginTop(marginTop) | 2833 | o.outerBox.SetMarginTop(marginTop) | ||
| 2834 | 2834 | ||||
| 2835 | // Show the omnibox | 2835 | // Show the omnibox | ||
M internal/ui/component/omnibox_navigation_state_test.go +1 -1
| @@ -360,7 +360,7 @@ func TestVisibleGhostSuggestion(t *testing.T) { | |||
| 360 | 360 | } | |
| 361 | 361 | } | |
| 362 | 362 | ||
| 363 | - | func TestVisibleGhostSuggestionRespectsVisibleLimit(t *testing.T) { | |
| 363 | + | func TestVisibleGhostSuggestionRespectsResultLimit(t *testing.T) { | |
| 364 | 364 | suggestions := []Suggestion{ | |
| 365 | 365 | {URL: "https://github.com/bnema/dumber"}, | |
| 366 | 366 | {URL: "https://gitlab.com/team/project"}, | |
| @@ -360,7 +360,7 @@ func TestVisibleGhostSuggestion(t *testing.T) { | |||||
| 360 | } | 360 | } | ||
| 361 | } | 361 | } | ||
| 362 | 362 | ||||
| 363 | - | func TestVisibleGhostSuggestionRespectsVisibleLimit(t *testing.T) { | 363 | + | func TestVisibleGhostSuggestionRespectsResultLimit(t *testing.T) { |
| 364 | suggestions := []Suggestion{ | 364 | suggestions := []Suggestion{ | ||
| 365 | {URL: "https://github.com/bnema/dumber"}, | 365 | {URL: "https://github.com/bnema/dumber"}, | ||
| 366 | {URL: "https://gitlab.com/team/project"}, | 366 | {URL: "https://gitlab.com/team/project"}, | ||
M internal/ui/component/omnibox_suggestions_test.go +1 -1
| @@ -79,7 +79,7 @@ func TestNavigableCount(t *testing.T) { | |||
| 79 | 79 | bangs, suggestions, favorites int | |
| 80 | 80 | want int | |
| 81 | 81 | }{ | |
| 82 | - | {"history beyond visible rows", false, ViewModeHistory, 0, limit, 30, limit}, | |
| 82 | + | {"history capped at results limit", false, ViewModeHistory, 0, limit + 5, 30, limit}, | |
| 83 | 83 | {"favorites capped at results limit", false, ViewModeFavorites, 0, 3, 30, limit}, | |
| 84 | 84 | {"bangs win over view mode", true, ViewModeHistory, 2, 8, 0, 2}, | |
| 85 | 85 | {"empty list", false, ViewModeFavorites, 4, 4, 0, 0}, | |
| @@ -79,7 +79,7 @@ func TestNavigableCount(t *testing.T) { | |||||
| 79 | bangs, suggestions, favorites int | 79 | bangs, suggestions, favorites int | ||
| 80 | want int | 80 | want int | ||
| 81 | }{ | 81 | }{ | ||
| 82 | - | {"history beyond visible rows", false, ViewModeHistory, 0, limit, 30, limit}, | 82 | + | {"history capped at results limit", false, ViewModeHistory, 0, limit + 5, 30, limit}, |
| 83 | {"favorites capped at results limit", false, ViewModeFavorites, 0, 3, 30, limit}, | 83 | {"favorites capped at results limit", false, ViewModeFavorites, 0, 3, 30, limit}, | ||
| 84 | {"bangs win over view mode", true, ViewModeHistory, 2, 8, 0, 2}, | 84 | {"bangs win over view mode", true, ViewModeHistory, 2, 8, 0, 2}, | ||
| 85 | {"empty list", false, ViewModeFavorites, 4, 4, 0, 0}, | 85 | {"empty list", false, ViewModeFavorites, 4, 4, 0, 0}, | ||