Browse Source

updated to restore original view title on enter

pull/7/head
David Haukeness 5 years ago
parent
commit
f61d212272
No known key found for this signature in database
GPG Key ID: A7F1091956853EF9
  1. 18
      main.go

18
main.go

@ -65,8 +65,14 @@ func viewTitle(viewName string, title string) { @@ -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 { @@ -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 { @@ -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

Loading…
Cancel
Save