Commit 3b99abf8 authored by Liam's avatar Liam Committed by GitHub

Merge pull request #56 from iamcodemaker/fix

fix vi mode no_eol functionality
parents 450161f9 752f91e9
......@@ -601,6 +601,19 @@ impl<'a, W: Write> Editor<'a, W> {
let buf = cur_buf!(self);
let buf_width = buf.width();
// Don't let the cursor go over the end!
let buf_num_chars = buf.num_chars();
if buf_num_chars < self.cursor {
self.cursor = buf_num_chars;
}
// Can't move past the last character in vi normal mode
if self.no_eol {
if self.cursor >= 1 && self.cursor == buf_num_chars {
self.cursor -= 1;
}
}
// Width of the current buffer lines (including autosuggestion)
let buf_widths = match self.current_autosuggestion() {
Some(suggestion) => suggestion.width(),
......@@ -666,19 +679,6 @@ impl<'a, W: Write> Editor<'a, W> {
try!(write!(self.out, "\r\n"));
}
// Don't let the cursor go over the end!
let buf_num_chars = buf.num_chars();
if buf_num_chars < self.cursor {
self.cursor = buf_num_chars;
}
// can't move past the last character in vi normal mode
if self.no_eol {
if self.cursor >= 1 && self.cursor == buf_num_chars {
self.cursor -= 1;
}
}
self.term_cursor_line = (new_total_width_to_cursor + w) / w;
// The term cursor is now on the bottom line. We may need to move the term cursor up
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment