Skip to content
Snippets Groups Projects
Commit 66cc5c99 authored by gwenn's avatar gwenn
Browse files

Handle vi redo last command

parent a74ef3c9
No related branches found
No related tags found
No related merge requests found
......@@ -83,6 +83,7 @@ pub struct EditState {
insert: bool, // vi only ?
// numeric arguments: http://web.mit.edu/gnu/doc/html/rlman_1.html#SEC7
num_args: i16,
last_cmd: Cmd, // vi only
}
#[derive(Debug, Clone, PartialEq)]
......@@ -103,6 +104,7 @@ impl EditState {
mode: config.edit_mode(),
insert: true,
num_args: 0,
last_cmd: Cmd::Noop,
}
}
......@@ -274,6 +276,7 @@ impl EditState {
let cmd = match key {
KeyPress::Char('$') |
KeyPress::End => Cmd::EndOfLine,
KeyPress::Char('.') => self.last_cmd.clone(), // vi-redo
// TODO KeyPress::Char('%') => Cmd::???, Move to the corresponding opening/closing bracket
KeyPress::Char('0') => Cmd::BeginningOfLine, // vi-zero: Vi move to the beginning of line.
KeyPress::Char('^') => Cmd::BeginningOfLine, // vi-first-print TODO Move to the first non-blank character of line.
......@@ -388,6 +391,9 @@ impl EditState {
_ => self.common(key, n, true),
};
debug!(target: "rustyline", "Vi command: {:?}", cmd);
if key != KeyPress::Char('.') {
self.last_cmd = cmd.clone();
}
Ok(cmd)
}
......@@ -406,6 +412,7 @@ impl EditState {
_ => self.common(key, 1, true),
};
debug!(target: "rustyline", "Vi insert: {:?}", cmd);
self.last_cmd = cmd.clone();
Ok(cmd)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment