Skip to content

Commit edd8e61

Browse files
committed
[closebrackets addon] Don't skip over quotes at the start of a string
Closes #4287
1 parent 344c8d5 commit edd8e61

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

addon/edit/closebrackets.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@
116116
if (opening && !range.empty()) {
117117
curType = "surround";
118118
} else if ((identical || !opening) && next == ch) {
119-
if (triples.indexOf(ch) >= 0 && cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == ch + ch + ch)
119+
if (identical && stringStartsAfter(cm, cur))
120+
curType = "both";
121+
else if (triples.indexOf(ch) >= 0 && cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == ch + ch + ch)
120122
curType = "skipThree";
121123
else
122124
curType = "skip";
@@ -192,4 +194,9 @@
192194
stream.start = stream.pos;
193195
}
194196
}
197+
198+
function stringStartsAfter(cm, pos) {
199+
var token = cm.getTokenAt(Pos(pos.line, pos.ch + 1))
200+
return /\bstring/.test(token.type) && token.start == pos.ch
201+
}
195202
});

0 commit comments

Comments
 (0)