Enha: remade within a popup

This commit is contained in:
Grail Finder
2026-02-19 08:35:21 +03:00
parent b861b92e5d
commit b18d96ac13
3 changed files with 39 additions and 103 deletions

View File

@@ -726,56 +726,3 @@ func scanFiles(dir, filter string) []string {
}
return files
}
func showFileCompletion(filter string) {
baseDir := cfg.CodingDir
if baseDir == "" {
baseDir = "."
}
complMatches = scanFiles(baseDir, filter)
go func() {
app.QueueUpdateDraw(func() {
if len(complMatches) == 0 {
hideCompletion() // Make sure hideCompletion also uses QueueUpdate if it modifies UI
return
}
// Limit the number of complMatches
if len(complMatches) > 10 {
complMatches = complMatches[:10]
}
// Update the popup's content
complPopup.Clear()
for _, f := range complMatches {
complPopup.AddItem(f, "", 0, nil)
}
// Update state and UI
complPopup.SetCurrentItem(0)
complActive = true
// Show the popup and set focus
pages.AddPage("complPopup", complPopup, true, true)
app.SetFocus(complPopup)
// No need to call app.Draw() here, QueueUpdateDraw does it automatically
})
}()
}
func insertCompletion() {
if complIndex >= 0 && complIndex < len(complMatches) {
match := complMatches[complIndex]
currentText := textArea.GetText()
atIdx := strings.LastIndex(currentText, "@")
if atIdx >= 0 {
before := currentText[:atIdx]
textArea.SetText(before+match, true)
}
}
hideCompletion()
}
func hideCompletion() {
complActive = false
complMatches = nil
pages.RemovePage("complPopup")
app.SetFocus(textArea)
app.Draw()
}