Skip to content

Commit

Permalink
Space required before bang (#337)
Browse files Browse the repository at this point in the history
* bang command expands only alone in buffer

* bang command requires space before
  • Loading branch information
elferherrera authored Mar 7, 2022
1 parent 8394b62 commit 56bc4a0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,13 @@ 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(last) = remainder.chars().last() {
if last != ' ' {
return None;
}
}

if let Some((_, indicator)) = &index {
if &buffer.trim() != indicator {
Expand All @@ -1053,12 +1059,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

0 comments on commit 56bc4a0

Please sign in to comment.