mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-11-10 00:59:44 +03:00
Fix % movement when not on opening character (#490)
Vim's behavior is to move to the closing match, if available. Prior to this commit, we were moving to the opening char. Fixes #480
This commit is contained in:
parent
453575dde6
commit
507741c9fd
@ -2224,7 +2224,9 @@ class MoveToMatchingBracket extends BaseMovement {
|
||||
|
||||
for (let i = position.character; i < text.length; i++) {
|
||||
if (PairMatcher.pairings[text[i]]) {
|
||||
return new Position(position.line, i);
|
||||
// We found an opening char, now move to the matching closing char
|
||||
const openPosition = new Position(position.line, i);
|
||||
return PairMatcher.nextPairedChar(openPosition, text[i], true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,20 @@ suite("Mode Normal", () => {
|
||||
end: ["((( ))|)"],
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: "Can handle % before opening brace",
|
||||
start: ['|one (two)'],
|
||||
keysPressed: '%',
|
||||
end: ["one (two|)"],
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: "Can handle % nested inside parens",
|
||||
start: ['(|one { two })'],
|
||||
keysPressed: '%',
|
||||
end: ["(one { two |})"],
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: "Can handle dw",
|
||||
start: ['one |two three'],
|
||||
|
Loading…
Reference in New Issue
Block a user