apply gwenn suggestions
@@ -25,6 +25,16 @@ pub fn execute<H: Helper>(
) -> Result<Status> {
use Status::{Proceed, Submit};
+ match cmd {
+ Cmd::EndOfFile | Cmd::AcceptLine | Cmd::AcceptOrInsertLine { .. } | Cmd::Newline => {
+ if s.has_hint() || !s.is_default_prompt() {
+ // Force a refresh without hints to leave the previous
+ // line as the user typed it after a newline.
+ s.refresh_line_with_msg(None)?;
+ }
+ }
+ _ => {}
+ };
match cmd {
Cmd::CompleteHint => {
complete_hint_line(s)?;
@@ -58,11 +68,6 @@ pub fn execute<H: Helper>(
s.edit_overwrite_char(c)?;
}
Cmd::EndOfFile => {
- if s.has_hint() || !s.is_default_prompt() {
- // Force a refresh without hints to leave the previous
- // line as the user typed it after a newline.
- s.refresh_line_with_msg(None)?;
- }
if s.line.is_empty() {
return Err(error::ReadlineError::Eof);
} else if !input_state.is_emacs_mode() {
@@ -119,12 +124,10 @@ pub fn execute<H: Helper>(
kill_ring.kill(&text, Mode::Append);
}
}
- Cmd::AcceptLine | Cmd::AcceptOrInsertLine { .. } | Cmd::Newline => {
- if s.has_hint() || !s.is_default_prompt() {
- // Force a refresh without hints to leave the previous
- // line as the user typed it after a newline.
- s.refresh_line_with_msg(None)?;
+ Cmd::Newline => {
+ s.edit_insert('\n', 1)?;
}
+ Cmd::AcceptLine | Cmd::AcceptOrInsertLine { .. } => {
let validation_result = s.validate()?;
let valid = validation_result.is_valid();
let end = s.line.is_end_of_input();
@@ -146,9 +149,6 @@ pub fn execute<H: Helper>(
s.edit_insert('\n', 1)?;
}
}
- (Cmd::Newline, ..) => {
- s.edit_insert('\n', 1)?;
- }
_ => unreachable!(),
}
}
