Skip to content

Commit

Permalink
Merge pull request #646 from gwenn/caret_no_whitespace
Browse files Browse the repository at this point in the history
Fix ViFirstPrint movement
  • Loading branch information
gwenn authored Aug 20, 2022
2 parents 5682cd3 + 9d42d75 commit f1f20ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ pub fn execute<H: Helper>(
}
Cmd::Move(Movement::ViFirstPrint) => {
s.edit_move_home()?;
s.edit_move_to_next_word(At::Start, Word::Big, 1)?;
if s.line.starts_with(char::is_whitespace) {
s.edit_move_to_next_word(At::Start, Word::Big, 1)?;
}
}
Cmd::Move(Movement::BackwardChar(n)) => {
// Move back a character.
Expand Down
10 changes: 10 additions & 0 deletions src/test/vi_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ fn caret() {
);
}

#[test]
fn caret_no_whitespace() {
assert_cursor(
EditMode::Vi,
("Hi", ""),
&[E::ESC, E::from('^'), E::ENTER],
("", "Hi"),
);
}

#[test]
fn a() {
assert_cursor(
Expand Down

0 comments on commit f1f20ac

Please sign in to comment.