[continuecomment addon] Continue comments when a newline is inserted before them

Fix issue where lastIndexOff was accidentally passed a negative
start position, which causes it to search from the end of the string.

Closes #6065
This commit is contained in:
Marijn Haverbeke 2019-11-17 14:44:17 +01:00
parent 74de67598c
commit 0f191d54ee
1 changed files with 2 additions and 1 deletions

View File

@ -32,7 +32,8 @@
lineCmt && (found = line.lastIndexOf(lineCmt, pos.ch - 1)) > -1 &&
/\bcomment\b/.test(cm.getTokenTypeAt({line: pos.line, ch: found + 1}))) {
// ...then don't continue it
} else if ((found = line.lastIndexOf(blockStart, pos.ch - blockStart.length)) > -1 &&
} else if (pos.ch >= blockStart.length &&
(found = line.lastIndexOf(blockStart, pos.ch - blockStart.length)) > -1 &&
found > end) {
// reuse the existing leading spaces/tabs/mixed
// or build the correct indent using CM's tab/indent options