Skip to content

Commit 2a28a9d

Browse files
committed
Change curly brace surround
1 parent 9bcacef commit 2a28a9d

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

keymap/vim.js

+18-4
Original file line numberDiff line numberDiff line change
@@ -2842,11 +2842,13 @@
28422842
if (typeof mirroredPairs[character] === 'boolean') {
28432843
openC = closeC = character
28442844
} else {
2845+
let pairs = mirroredPairs[character] ? mirroredPairs : multilinePairs
2846+
28452847
if (openCs.includes(character)) {
28462848
openC = character
2847-
closeC = mirroredPairs[character]
2849+
closeC = pairs[character]
28482850
} else {
2849-
openC = mirroredPairs[character]
2851+
openC = pairs[character]
28502852
closeC = character
28512853
}
28522854
}
@@ -2882,8 +2884,20 @@
28822884
cm.replaceRange(text, openPos, closePos)
28832885
}
28842886

2885-
function replaceMultilineSurround () {
2886-
2887+
function replaceCharacterAt (cm, character, position) {
2888+
var pos = {
2889+
ch: position.ch + 1,
2890+
line: position.line
2891+
}
2892+
cm.replaceRange(character, position, pos)
2893+
}
2894+
2895+
function replaceMultilineSurround (cm, searchCharacter, replaceCharacter) {
2896+
var tmp = selectCompanionObject(cm, cursor, searchCharacter, true)
2897+
const replacePair = transformCharacterPair(replaceCharacter)
2898+
2899+
replaceCharacterAt(cm, replacePair[0], tmp.start)
2900+
replaceCharacterAt(cm, replacePair[1], { ch: tmp.end.ch - 1, line: tmp.end.line })
28872901
}
28882902

28892903
if (mirroredPairs[actionArgs.search]) {

0 commit comments

Comments
 (0)