Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Space required before bang #337

Merged
merged 2 commits into from
Mar 7, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
bang command requires space before
  • Loading branch information
elferherrera committed Mar 7, 2022
commit e3a79b6bb188e7e69df095e46ecf081f91217c99
10 changes: 5 additions & 5 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,10 +1039,10 @@ impl Reedline {
/// Parses the ! command to replace entries from the history
fn parse_bang_command(&mut self) -> Option<ReedlineEvent> {
let buffer = self.editor.get_buffer();
let (string, index) = parse_selection_char(buffer, &'!');
let (remainder, index) = parse_selection_char(buffer, &'!');

if let Some((_, indicator)) = &index {
if &buffer.trim() != indicator {
if let Some(last) = remainder.chars().last() {
if last != ' ' {
return None;
}
}
Expand All @@ -1053,12 +1053,12 @@ impl Reedline {
.iter_chronologic()
.rev()
.next()
.map(|history| (string.len(), indicator.len(), history.clone()))
.map(|history| (remainder.len(), indicator.len(), history.clone()))
} else {
self.history
.iter_chronologic()
.nth(index)
.map(|history| (string.len(), indicator.len(), history.clone()))
.map(|history| (remainder.len(), indicator.len(), history.clone()))
}
});

Expand Down