mirror of
https://github.com/Rudi9719/kbtui.git
synced 2026-03-22 09:57:24 +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 {
|
func getViewTitle(viewName string) string {
|
||||||
view, _ := g.View(viewName)
|
view, err := g.View(viewName)
|
||||||
return view.Title
|
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) {
|
func popupView(viewName string) {
|
||||||
@ -336,9 +342,9 @@ func handleTab() error {
|
|||||||
rLen := len(resultSlice)
|
rLen := len(resultSlice)
|
||||||
lcp := longestCommonPrefix(resultSlice)
|
lcp := longestCommonPrefix(resultSlice)
|
||||||
if lcp != "" {
|
if lcp != "" {
|
||||||
originalViewTitle := strings.Split(getViewTitle("Input"), "||")[0]
|
originalViewTitle := getViewTitle("Input")
|
||||||
newViewTitle := ""
|
newViewTitle := ""
|
||||||
if rLen >= 1 {
|
if rLen >= 1 && originalViewTitle != "" {
|
||||||
if rLen == 1 {
|
if rLen == 1 {
|
||||||
newViewTitle = originalViewTitle
|
newViewTitle = originalViewTitle
|
||||||
} else if rLen <= 5 {
|
} else if rLen <= 5 {
|
||||||
@ -613,6 +619,10 @@ func handleInput(viewName string) error {
|
|||||||
} else {
|
} else {
|
||||||
go sendChat(inputString)
|
go sendChat(inputString)
|
||||||
}
|
}
|
||||||
|
// restore any tab completion view titles on input commit
|
||||||
|
if newViewTitle := getViewTitle(viewName); newViewTitle != "" {
|
||||||
|
viewTitle(viewName, newViewTitle)
|
||||||
|
}
|
||||||
|
|
||||||
go populateList()
|
go populateList()
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user