From eeca909b6573e14b51f9fe5ce5451c90ab95a00e Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Thu, 19 Feb 2026 08:53:09 +0300 Subject: Feat: working tab completion in shell mode --- popups.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'popups.go') diff --git a/popups.go b/popups.go index c83bce4..db314e4 100644 --- a/popups.go +++ b/popups.go @@ -70,6 +70,10 @@ func showModelSelectionPopup() { pages.RemovePage("modelSelectionPopup") return nil } + if event.Key() == tcell.KeyRune && event.Rune() == 'x' { + pages.RemovePage("modelSelectionPopup") + return nil + } return event }) modal := func(p tview.Primitive, width, height int) tview.Primitive { @@ -163,6 +167,10 @@ func showAPILinkSelectionPopup() { pages.RemovePage("apiLinkSelectionPopup") return nil } + if event.Key() == tcell.KeyRune && event.Rune() == 'x' { + pages.RemovePage("apiLinkSelectionPopup") + return nil + } return event }) modal := func(p tview.Primitive, width, height int) tview.Primitive { @@ -229,6 +237,10 @@ func showUserRoleSelectionPopup() { pages.RemovePage("userRoleSelectionPopup") return nil } + if event.Key() == tcell.KeyRune && event.Rune() == 'x' { + pages.RemovePage("userRoleSelectionPopup") + return nil + } return event }) modal := func(p tview.Primitive, width, height int) tview.Primitive { @@ -297,6 +309,10 @@ func showBotRoleSelectionPopup() { pages.RemovePage("botRoleSelectionPopup") return nil } + if event.Key() == tcell.KeyRune && event.Rune() == 'x' { + pages.RemovePage("botRoleSelectionPopup") + return nil + } return event }) modal := func(p tview.Primitive, width, height int) tview.Primitive { @@ -322,6 +338,16 @@ func showFileCompletionPopup(filter string) { if len(complMatches) == 0 { return } + // If only one match, auto-complete without showing popup + if len(complMatches) == 1 { + currentText := textArea.GetText() + atIdx := strings.LastIndex(currentText, "@") + if atIdx >= 0 { + before := currentText[:atIdx] + textArea.SetText(before+complMatches[0], true) + } + return + } widget := tview.NewList().ShowSecondaryText(false). SetSelectedBackgroundColor(tcell.ColorGray) widget.SetTitle("file completion").SetBorder(true) @@ -337,6 +363,17 @@ func showFileCompletionPopup(filter string) { } pages.RemovePage("fileCompletionPopup") }) + widget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { + if event.Key() == tcell.KeyEscape { + pages.RemovePage("fileCompletionPopup") + return nil + } + if event.Key() == tcell.KeyRune && event.Rune() == 'x' { + pages.RemovePage("fileCompletionPopup") + return nil + } + return event + }) modal := func(p tview.Primitive, width, height int) tview.Primitive { return tview.NewFlex(). AddItem(nil, 0, 1, false). -- cgit v1.2.3