Merge pull request #891 from pranavraja/master

search: Only update lastSearch on ENTER
This commit is contained in:
Zachary Yedidia 2017-11-19 15:47:05 -05:00 committed by GitHub
commit e4c2f5d259
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -64,7 +64,12 @@ func HandleSearchEvent(event tcell.Event, v *View) {
// Exit the search mode
ExitSearch(v)
return
case tcell.KeyCtrlQ, tcell.KeyCtrlC, tcell.KeyEnter:
case tcell.KeyEnter:
// If the user has pressed Enter, they want this to be the lastSearch
lastSearch = messenger.response
EndSearch()
return
case tcell.KeyCtrlQ, tcell.KeyCtrlC:
// Done
EndSearch()
return
@ -179,9 +184,7 @@ func Search(searchStr string, v *View, down bool) {
found = searchUp(r, v, v.Buf.End(), searchStart)
}
}
if found {
lastSearch = searchStr
} else {
if !found {
v.Cursor.ResetSelection()
}
}