Skip to content

Commit

Permalink
Merge pull request #2572 from Shadaraman/master
Browse files Browse the repository at this point in the history
Fixes #2569. Fix vi{ for nested braces.
  • Loading branch information
xconverge authored Apr 26, 2018
2 parents f33ed92 + 194c681 commit 5da0ab1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/actions/motion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1433,18 +1433,14 @@ export abstract class MoveInsideCharacter extends BaseMovement {
}
} else {
startPos = startPlusOne;
if (vimState.currentMode === ModeName.Visual) {
endPos = endPos.getLeftThroughLineBreaks();
}
}

// If the closing character is the first on the line, don't swallow it.
if (!this.includeSurrounding) {
if (endPos.getLeft().isInLeadingWhitespace()) {
// If the closing character is the first on the line, don't swallow it.
if (endPos.isInLeadingWhitespace()) {
endPos = endPos.getLineBegin();
if (vimState.currentMode === ModeName.Visual) {
endPos = endPos.getLeftThroughLineBreaks();
}
}

if (vimState.currentMode === ModeName.Visual) {
endPos = endPos.getLeftThroughLineBreaks();
}
}

Expand Down
16 changes: 16 additions & 0 deletions test/mode/modeVisual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,22 @@ suite('Mode Visual', () => {
endMode: ModeName.Normal,
});

newTest({
title: 'Can do vi{ on outer pair of nested braces',
start: ['{', ' te|st', ' {', ' test', ' }', '}'],
keysPressed: 'vi{d',
end: ['{', '|}'],
endMode: ModeName.Normal,
});

newTest({
title: 'Can do vi{ on braces indented by 1 and preserve indent',
start: ['{', ' t|est', ' }'],
keysPressed: 'vi{d',
end: ['{', '| }'],
endMode: ModeName.Normal,
});

suite('handles replace in visual mode', () => {
newTest({
title: 'Can do a single line replace',
Expand Down

0 comments on commit 5da0ab1

Please sign in to comment.