mirror of
https://github.com/Rudi9719/kbtui.git
synced 2026-03-22 07:37:23 +00:00
updated to restore original view title on enter
This commit is contained in:
18
main.go
18
main.go
@ -65,8 +65,14 @@ func viewTitle(viewName string, title string) {
|
||||
}
|
||||
|
||||
func getViewTitle(viewName string) string {
|
||||
view, _ := g.View(viewName)
|
||||
return view.Title
|
||||
view, err := g.View(viewName)
|
||||
if err != nil {
|
||||
// in case there is active tab completion, filter that to just the view title and not the completion options.
|
||||
writeToView("Feed", fmt.Sprintf("Error getting view title: %s", err))
|
||||
return ""
|
||||
} else {
|
||||
return strings.Split(view.Title, "||")[0]
|
||||
}
|
||||
}
|
||||
|
||||
func popupView(viewName string) {
|
||||
@ -336,9 +342,9 @@ func handleTab() error {
|
||||
rLen := len(resultSlice)
|
||||
lcp := longestCommonPrefix(resultSlice)
|
||||
if lcp != "" {
|
||||
originalViewTitle := strings.Split(getViewTitle("Input"), "||")[0]
|
||||
originalViewTitle := getViewTitle("Input")
|
||||
newViewTitle := ""
|
||||
if rLen >= 1 {
|
||||
if rLen >= 1 && originalViewTitle != "" {
|
||||
if rLen == 1 {
|
||||
newViewTitle = originalViewTitle
|
||||
} else if rLen <= 5 {
|
||||
@ -613,6 +619,10 @@ func handleInput(viewName string) error {
|
||||
} else {
|
||||
go sendChat(inputString)
|
||||
}
|
||||
// restore any tab completion view titles on input commit
|
||||
if newViewTitle := getViewTitle(viewName); newViewTitle != "" {
|
||||
viewTitle(viewName, newViewTitle)
|
||||
}
|
||||
|
||||
go populateList()
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user