Skip to content

Commit

Permalink
fix(add-remove-comment): fixed line ending reg exp
Browse files Browse the repository at this point in the history
  • Loading branch information
YuryShkoda committed May 22, 2023
1 parent 9e2a2ae commit d53af50
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/commands/addRemoveComment/addRemoveComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class AddRemoveCommentCommand {
CRLF = `\r\n`,
LF = `\n`
}
const lineEnding = new RegExp(LineEndings.CRLF + `$`).test(text)
const lineEnding = new RegExp(LineEndings.CRLF).test(text)
? LineEndings.CRLF
: LineEndings.LF

Expand All @@ -68,8 +68,7 @@ export class AddRemoveCommentCommand {
const editedLines = lines
.reduce((acc: string[], line: string, i: number) => {
if (i >= start.line && i <= end.line) {
// INFO: temporary removal of carriage returns (added back if relevant in join below)
acc.push(this.addRemoveCommentToLine(line.replace(lineEnding, '')))
acc.push(this.addRemoveCommentToLine(line))
}

return acc
Expand Down

0 comments on commit d53af50

Please sign in to comment.