Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix steep:ignore does not work with CR/LF #1406

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/steep/ast/ignore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,14 @@ def ignored_diagnostics
def self.parse(comment, buffer)
return unless comment.inline?

comment_location = RBS::Location.new(buffer, comment.loc.expression.begin_pos, comment.loc.expression.end_pos)
begin_pos = buffer.loc_to_pos([comment.loc.line, comment.loc.column])
end_pos = buffer.loc_to_pos([comment.loc.last_line, comment.loc.last_column])
comment_location = RBS::Location.new(buffer, begin_pos, end_pos)
scanner = BufferScanner.new(comment_location)

scanner.scan(/#/)
scanner.skip(/\s*/)

begin_pos = comment.location.expression.begin_pos
end_pos = comment.location.expression.end_pos

case
when loc = scanner.scan(/steep:ignore:start\b/)
scanner.skip(/\s*/)
Expand Down
15 changes: 15 additions & 0 deletions test/ast/ignore_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,19 @@ def test_parse_ignore__diagnostics
assert_equal "steep:ignore Foo, Bar,", ignore.location.source
end
end

def test_parse_ignore__crlf
_, comments, buf = parse(<<~RUBY)
\r
# steep:ignore Foo
# steep:ignore Foo, Bar,
RUBY
Steep::AST::Ignore.parse(comments[0], buf).tap do |ignore|
assert_instance_of Ignore::IgnoreLine, ignore
end

Steep::AST::Ignore.parse(comments[1], buf).tap do |ignore|
assert_instance_of Ignore::IgnoreLine, ignore
end
end
end
Loading