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

Omit first word in hash backwards search #506

Merged
merged 2 commits into from
Jul 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,10 @@ class CommandHash extends BaseCommand {
vimState.searchState = new SearchState(-1, vimState.cursorPosition, currentWord);

do {
vimState.cursorPosition = vimState.searchState.getNextSearchMatchPosition(vimState.cursorPosition).pos;
// use getWordLeft() on position to start at the beginning of the word.
// this ensures that any matches happen ounside of the word currently selected,
// which are the desired semantics for this motion.
vimState.cursorPosition = vimState.searchState.getNextSearchMatchPosition(vimState.cursorPosition.getWordLeft()).pos;
} while (CommandStar.GetWordAtPosition(vimState.cursorPosition) !== currentWord);

return vimState;
Expand Down
7 changes: 7 additions & 0 deletions test/mode/normalModeTests/motions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,13 @@ suite("Motions in Normal Mode", () => {
end: ['|blah duh blah duh blah']
});

newTest({
title: "Can handle # already on the word",
start: ['one o|ne'],
keysPressed: '#',
end: ['|one one']
});

newTest({
title: "Can handle ##",
start: ['blah duh blah duh |blah'],
Expand Down