fix: clear ghost text on position timeout instead of forcing bad placement
- commit
- 3cd9d2ea65d158fb5181636fdb654f0acf16801d
- author
- brice · · 2026-01-26 05:56 UTC
- parent
- d8bf31c
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email - refs
- tag: v0.26.2
1 file · +18 -4
M internal/ui/component/omnibox.go +18 -4
| @@ -871,15 +871,29 @@ func (o *Omnibox) shouldSkipGhostUpdate(originalInput string) bool { | |||
| 871 | 871 | } | |
| 872 | 872 | ||
| 873 | 873 | func (o *Omnibox) ghostPositionReady(attempt int) bool { | |
| 874 | - | if attempt >= ghostPositionMaxAttempts { | |
| 875 | - | return true | |
| 876 | - | } | |
| 877 | 874 | entryWidth := o.entry.GetAllocatedWidth() | |
| 878 | 875 | overlayWidth := 0 | |
| 879 | 876 | if o.entryOverlay != nil { | |
| 880 | 877 | overlayWidth = o.entryOverlay.GetAllocatedWidth() | |
| 881 | 878 | } | |
| 882 | - | return entryWidth > 0 && overlayWidth > 0 | |
| 879 | + | ||
| 880 | + | if entryWidth > 0 && overlayWidth > 0 { | |
| 881 | + | return true | |
| 882 | + | } | |
| 883 | + | ||
| 884 | + | // Max attempts reached but widgets still not allocated - give up | |
| 885 | + | if attempt >= ghostPositionMaxAttempts { | |
| 886 | + | log := logging.FromContext(o.ctx) | |
| 887 | + | log.Debug(). | |
| 888 | + | Int("attempt", attempt). | |
| 889 | + | Int("entryWidth", entryWidth). | |
| 890 | + | Int("overlayWidth", overlayWidth). | |
| 891 | + | Msg("ghost position timeout, clearing ghost text") | |
| 892 | + | o.clearGhostText() | |
| 893 | + | return false | |
| 894 | + | } | |
| 895 | + | ||
| 896 | + | return false | |
| 883 | 897 | } | |
| 884 | 898 | ||
| 885 | 899 | func (o *Omnibox) retryGhostPosition(originalInput, suffix string, attempt int) { | |
| @@ -871,15 +871,29 @@ func (o *Omnibox) shouldSkipGhostUpdate(originalInput string) bool { | |||||
| 871 | } | 871 | } | ||
| 872 | 872 | ||||
| 873 | func (o *Omnibox) ghostPositionReady(attempt int) bool { | 873 | func (o *Omnibox) ghostPositionReady(attempt int) bool { | ||
| 874 | - | if attempt >= ghostPositionMaxAttempts { | |||
| 875 | - | return true | |||
| 876 | - | } | |||
| 877 | entryWidth := o.entry.GetAllocatedWidth() | 874 | entryWidth := o.entry.GetAllocatedWidth() | ||
| 878 | overlayWidth := 0 | 875 | overlayWidth := 0 | ||
| 879 | if o.entryOverlay != nil { | 876 | if o.entryOverlay != nil { | ||
| 880 | overlayWidth = o.entryOverlay.GetAllocatedWidth() | 877 | overlayWidth = o.entryOverlay.GetAllocatedWidth() | ||
| 881 | } | 878 | } | ||
| 882 | - | return entryWidth > 0 && overlayWidth > 0 | 879 | + | |
| 880 | + | if entryWidth > 0 && overlayWidth > 0 { | |||
| 881 | + | return true | |||
| 882 | + | } | |||
| 883 | + | ||||
| 884 | + | // Max attempts reached but widgets still not allocated - give up | |||
| 885 | + | if attempt >= ghostPositionMaxAttempts { | |||
| 886 | + | log := logging.FromContext(o.ctx) | |||
| 887 | + | log.Debug(). | |||
| 888 | + | Int("attempt", attempt). | |||
| 889 | + | Int("entryWidth", entryWidth). | |||
| 890 | + | Int("overlayWidth", overlayWidth). | |||
| 891 | + | Msg("ghost position timeout, clearing ghost text") | |||
| 892 | + | o.clearGhostText() | |||
| 893 | + | return false | |||
| 894 | + | } | |||
| 895 | + | ||||
| 896 | + | return false | |||
| 883 | } | 897 | } | ||
| 884 | 898 | ||||
| 885 | func (o *Omnibox) retryGhostPosition(originalInput, suffix string, attempt int) { | 899 | func (o *Omnibox) retryGhostPosition(originalInput, suffix string, attempt int) { | ||