Skip to content

Commit 66e559d

Browse files
committed
Preserve CRLF boundaries when deleting comments
1 parent 5de6ecd commit 66e559d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/rbs/rewriter.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ def replace_comment(comment, content:)
4343
def delete_comment(comment)
4444
location = comment.location or raise "Comment must have a location"
4545
line_start = location.start_pos - location.start_column
46-
line_end = location.end_pos + 1
46+
line_end = location.end_pos
47+
line_end += 1 if buffer.content[line_end] == "\r"
48+
line_end += 1 if buffer.content[line_end] == "\n"
4749
loc = Location.new(buffer, line_start, line_end)
4850
rewrite(loc, "")
4951
end

0 commit comments

Comments
 (0)