Skip to content

Commit 419aa76

Browse files
committed
[python mode] Fix invalid interpretation of punctuation-like comment/string tokens
Closes codemirror#5343
1 parent c824c22 commit 419aa76

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

mode/python/python.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,16 @@
254254
if (current == ":" && !state.lambda && top(state).type == "py")
255255
pushPyScope(state);
256256

257-
var delimiter_index = current.length == 1 ? "[({".indexOf(current) : -1;
258-
if (delimiter_index != -1)
259-
pushBracketScope(stream, state, "])}".slice(delimiter_index, delimiter_index+1));
260-
261-
delimiter_index = "])}".indexOf(current);
262-
if (delimiter_index != -1) {
263-
if (top(state).type == current) state.indent = state.scopes.pop().offset - hangingIndent
264-
else return ERRORCLASS;
257+
if (current.length == 1 && !/string|comment/.test(style)) {
258+
var delimiter_index = "[({".indexOf(current);
259+
if (delimiter_index != -1)
260+
pushBracketScope(stream, state, "])}".slice(delimiter_index, delimiter_index+1));
261+
262+
delimiter_index = "])}".indexOf(current);
263+
if (delimiter_index != -1) {
264+
if (top(state).type == current) state.indent = state.scopes.pop().offset - hangingIndent
265+
else return ERRORCLASS;
266+
}
265267
}
266268
if (state.dedent > 0 && stream.eol() && top(state).type == "py") {
267269
if (state.scopes.length > 1) state.scopes.pop();

0 commit comments

Comments
 (0)