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 #1674: repeating . with characters like " or ) leaves cursor in wrong place #1700

Merged
merged 4 commits into from
May 21, 2017
Merged
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
15 changes: 1 addition & 14 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,24 +883,11 @@ export class ModeHandler implements vscode.Disposable {
// delay the macro recording
actionToRecord = undefined;
} else {
/**
* For these characters, VSCode will insert two characters, but put
* the cursor only to the right 1. We have to adjust the cursor
* appropriately for macros in that case.
*/
const startsWithPairedCharacter = (x: string) =>
x.startsWith("(") ||
x.startsWith("[") ||
x.startsWith("[") ||
x.startsWith("'") ||
x.startsWith("\"") ||
x.startsWith("{");

// Push document content change to the stack
lastAction.contentChanges = lastAction.contentChanges.concat(
vimState.historyTracker.currentContentChanges.map(x => ({
textDiff: x,
positionDiff: startsWithPairedCharacter(x.text) ? new PositionDiff(0, -1) : new PositionDiff(0, 0),
positionDiff: new PositionDiff(0, 0)
Copy link
Member

Choose a reason for hiding this comment

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

Can this be removed now?

}))
);
vimState.historyTracker.currentContentChanges = [];
Expand Down