1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-10 15:04:32 +03:00

termwiz: line editor: fix a couple of bugs

* ctrl-R to find a line and then hit enter would cause the search
  text rather than the match text to be returned and run!
* When exiting the editor, clear to end of screen to make sure
  that we clean up any UI from the incremental search status
This commit is contained in:
Wez Furlong 2020-04-10 21:10:42 -07:00
parent d4df39f793
commit b3a57f0d1c

View File

@ -301,7 +301,8 @@ impl<'term> LineEditor<'term> {
self.state = EditorState::Inactive; self.state = EditorState::Inactive;
if let Some(move_end) = self.move_to_editor_end.take() { if let Some(move_end) = self.move_to_editor_end.take() {
self.terminal.render(&[move_end])?; self.terminal
.render(&[move_end, Change::ClearToEndOfScreen(Default::default())])?;
} }
self.terminal.flush()?; self.terminal.flush()?;
@ -788,7 +789,14 @@ impl<'term> LineEditor<'term> {
match action { match action {
Action::Cancel => self.state = EditorState::Cancelled, Action::Cancel => self.state = EditorState::Cancelled,
Action::NoAction => {} Action::NoAction => {}
Action::AcceptLine => self.state = EditorState::Accepted, Action::AcceptLine => {
// Make sure that hitting Enter for a line that
// shows in the incremental search causes that
// line to be accepted, rather than the search pattern!
self.cancel_search_state();
self.state = EditorState::Accepted;
}
Action::EndOfFile => { Action::EndOfFile => {
return Err( return Err(
std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "End Of File").into(), std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "End Of File").into(),