manifoldco / promptui

Interactive prompt for command-line applications

Home Page:https://www.manifold.co

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Help text suggests arrows in Vim mode

camuthig opened this issue · comments

When enabling Vim mode in a Select, the help text still suggests using arrow keys to choose between items. It would be helpful if this would swap to suggesting h,j,k,l, instead.

Playing around with this some, I think something like the below could provide the desired results. Happy to make a pull request if you think something like this could work

func (s *Select) setKeys() {
	if s.Keys != nil {
		return
	}

	if s.IsVimMode {
		s.Keys = &SelectKeys{
			Prev:     Key{Code: KeyPrev, Display: "k"},
			Next:     Key{Code: KeyNext, Display: "j"},
			PageUp:   Key{Code: KeyBackward, Display: "h"},
			PageDown: Key{Code: KeyForward, Display: "l"},
			Search:   Key{Code: '/', Display: "/"},
		}
	} else {
		s.Keys = &SelectKeys{
			Prev:     Key{Code: KeyPrev, Display: KeyPrevDisplay},
			Next:     Key{Code: KeyNext, Display: KeyNextDisplay},
			PageUp:   Key{Code: KeyBackward, Display: KeyBackwardDisplay},
			PageDown: Key{Code: KeyForward, Display: KeyForwardDisplay},
			Search:   Key{Code: '/', Display: "/"},
		}
	}
}