detached 603f4ba

fix(omnibox): clip ghost text to entry bounds and fix stale check race

commit
603f4ba5f5699b2d33256dc4ac8a315bf575aaa6
author
brice · · 2026-01-24 04:04 UTC
parent
88b49b5
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +12 -9
M internal/ui/component/omnibox.go +12 -9
@@ -425,9 +425,11 @@ func (o *Omnibox) initEntry() error {
425425 o.ghostLabel.SetValign(gtk.AlignCenterValue) // Center vertically to match entry's centered text
426426 o.ghostLabel.SetXalign(0)
427427 o.ghostLabel.SetVisible(false)
428- o.ghostLabel.SetCanTarget(false) // Don't intercept clicks
428+ o.ghostLabel.SetCanTarget(false) // Don't intercept clicks
429+ o.ghostLabel.SetEllipsize(pango.EllipsizeEndValue) // Truncate with ellipsis if too long
429430
430431 o.entryOverlay.AddOverlay(&o.ghostLabel.Widget)
432+ o.entryOverlay.SetClipOverlay(&o.ghostLabel.Widget, true) // Clip ghost text to entry bounds
431433
432434 return nil
433435 }
@@ -741,15 +743,8 @@ func (o *Omnibox) setGhostText(originalInput, suffix, fullText string) {
741743 return
742744 }
743745
746+ // Store ghost state optimistically - will be validated on main thread
744747 o.mu.Lock()
745- currentInput := o.realInput
746- // Check if input has changed since the autocomplete query was made
747- // Skip this check when originalInput is empty (row selection replaces full input)
748- if originalInput != "" && currentInput != originalInput {
749- o.mu.Unlock()
750- // Input changed, skip this stale result - a newer query will handle it
751- return
752- }
753748 o.ghostSuffix = suffix
754749 o.ghostFullText = fullText
755750 o.hasGhostText = true
@@ -760,6 +755,14 @@ func (o *Omnibox) setGhostText(originalInput, suffix, fullText string) {
760755 return false
761756 }
762757
758+ // Check if input has changed since the autocomplete query was made
759+ // This check runs on GTK main thread where entry.GetText() is reliable
760+ // Skip this check when originalInput is empty (row selection replaces full input)
761+ if originalInput != "" && o.entry.GetText() != originalInput {
762+ // Input changed, skip this stale result - a newer query will handle it
763+ return false
764+ }
765+
763766 // Get the entry's Pango context and create a layout to measure text width
764767 pangoCtx := o.entry.GetPangoContext()
765768 if pangoCtx == nil {
@@ -425,9 +425,11 @@ func (o *Omnibox) initEntry() error {
425 o.ghostLabel.SetValign(gtk.AlignCenterValue) // Center vertically to match entry's centered text425 o.ghostLabel.SetValign(gtk.AlignCenterValue) // Center vertically to match entry's centered text
426 o.ghostLabel.SetXalign(0)426 o.ghostLabel.SetXalign(0)
427 o.ghostLabel.SetVisible(false)427 o.ghostLabel.SetVisible(false)
428- o.ghostLabel.SetCanTarget(false) // Don't intercept clicks428+ o.ghostLabel.SetCanTarget(false) // Don't intercept clicks
429+ o.ghostLabel.SetEllipsize(pango.EllipsizeEndValue) // Truncate with ellipsis if too long
429 430
430 o.entryOverlay.AddOverlay(&o.ghostLabel.Widget)431 o.entryOverlay.AddOverlay(&o.ghostLabel.Widget)
432+ o.entryOverlay.SetClipOverlay(&o.ghostLabel.Widget, true) // Clip ghost text to entry bounds
431 433
432 return nil434 return nil
433 }435 }
@@ -741,15 +743,8 @@ func (o *Omnibox) setGhostText(originalInput, suffix, fullText string) {
741 return743 return
742 }744 }
743 745
746+ // Store ghost state optimistically - will be validated on main thread
744 o.mu.Lock()747 o.mu.Lock()
745- currentInput := o.realInput
746- // Check if input has changed since the autocomplete query was made
747- // Skip this check when originalInput is empty (row selection replaces full input)
748- if originalInput != "" && currentInput != originalInput {
749- o.mu.Unlock()
750- // Input changed, skip this stale result - a newer query will handle it
751- return
752- }
753 o.ghostSuffix = suffix748 o.ghostSuffix = suffix
754 o.ghostFullText = fullText749 o.ghostFullText = fullText
755 o.hasGhostText = true750 o.hasGhostText = true
@@ -760,6 +755,14 @@ func (o *Omnibox) setGhostText(originalInput, suffix, fullText string) {
760 return false755 return false
761 }756 }
762 757
758+ // Check if input has changed since the autocomplete query was made
759+ // This check runs on GTK main thread where entry.GetText() is reliable
760+ // Skip this check when originalInput is empty (row selection replaces full input)
761+ if originalInput != "" && o.entry.GetText() != originalInput {
762+ // Input changed, skip this stale result - a newer query will handle it
763+ return false
764+ }
765+
763 // Get the entry's Pango context and create a layout to measure text width766 // Get the entry's Pango context and create a layout to measure text width
764 pangoCtx := o.entry.GetPangoContext()767 pangoCtx := o.entry.GetPangoContext()
765 if pangoCtx == nil {768 if pangoCtx == nil {

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close