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

Fixes #1588: <C-a> does wrong things if cursor is to the right of a number (and there's a number on the next line) #1617

Merged
merged 3 commits into from
May 1, 2017
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: 3 additions & 2 deletions src/motion/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export class Position extends vscode.Position {
}
}

// Iterates through words on the same line, starting from the current position.
public static *IterateWords(start: Position): Iterable<{ start: Position, end: Position, word: string }> {
const text = TextEditor.getLineAt(start).text;
let wordEnd = start.getCurrentWordEnd(true);
Expand All @@ -275,11 +276,11 @@ export class Position extends vscode.Position {
word: word,
};

if (wordEnd.isLineEnd()) {
if (wordEnd.getRight().isLineEnd()) {
return;
}
start = start.getWordRight();
wordEnd = start.getCurrentWordEnd();
wordEnd = start.getCurrentWordEnd(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gah - we need to use more keyword arguments. e.g. i have no idea what this true means, but if it was start.getCurrentWordEnd({ exclusive: true }), that would be much better.

Not pertinent to this PR, but it's been on my mind.

} while (true);
}

Expand Down
7 changes: 7 additions & 0 deletions test/mode/modeNormal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,13 @@ suite("Mode Normal", () => {
end: ["test|1abc"]
});

newTest({
title: "can ctrl-a properly on multiple lines",
start: ["id: 1|,", "someOtherId: 1"],
keysPressed: "<C-a>",
end: ["id: 1|,", "someOtherId: 1"]
});

newTest({
title: "can do Y",
start: ["|blah blah"],
Expand Down