Skip to content

Commit

Permalink
[continuecomment addon] Continue comments when a newline is inserted …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
marijnh committed Nov 17, 2019
1 parent 74de675 commit 0f191d5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion addon/comment/continuecomment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0f191d5

Please sign in to comment.