Skip to content

Commit

Permalink
fix: Fixed comment folding bugs for html (xml like languages) (#4910)
Browse files Browse the repository at this point in the history
  • Loading branch information
anijanyan authored Oct 15, 2022
1 parent 6bff7b4 commit 5279a8a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/edit_session/folding.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,12 +593,12 @@ function Folding() {
if (dir != 1) {
do {
token = iterator.stepBackward();
} while (token && re.test(token.type));
iterator.stepForward();
} while (token && re.test(token.type) && !/^comment.end/.test(token.type));
token = iterator.stepForward();
}

range.start.row = iterator.getCurrentTokenRow();
range.start.column = iterator.getCurrentTokenColumn() + 2;
range.start.column = iterator.getCurrentTokenColumn() + (/^comment.start/.test(token.type) ? token.value.length : 2);

iterator = new TokenIterator(this, row, column);

Expand All @@ -613,13 +613,16 @@ function Folding() {
} else if (iterator.$row > lastRow) {
break;
}
} while (token && re.test(token.type));
} while (token && re.test(token.type) && !/^comment.start/.test(token.type));
token = iterator.stepBackward();
} else
token = iterator.getCurrentToken();

range.end.row = iterator.getCurrentTokenRow();
range.end.column = iterator.getCurrentTokenColumn() + token.value.length - 2;
range.end.column = iterator.getCurrentTokenColumn();
if (!/^comment.end/.test(token.type)) {
range.end.column += token.value.length - 2;
}
return range;
}
};
Expand Down

0 comments on commit 5279a8a

Please sign in to comment.