Skip to content

Commit

Permalink
Parse comments that start with multiple hashes (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
castwide committed Jul 11, 2023
1 parent 60ef17d commit 0077f5c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/solargraph/source_map/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def remove_inline_comment_hashes comment
started = false
comment.lines.each { |l|
# Trim the comment and minimum leading whitespace
p = l.encode('UTF-8', invalid: :replace, replace: '?').gsub(/^#/, '')
p = l.encode('UTF-8', invalid: :replace, replace: '?').gsub(/^#+/, '')
if num.nil? && !p.strip.empty?
num = p.index(/[^ ]/)
started = true
Expand Down
16 changes: 16 additions & 0 deletions spec/source_map/mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1589,4 +1589,20 @@ def barbaz; end
Solargraph::SourceMap.load('spec/fixtures/invalid_node_comment.rb')
}.not_to raise_error
end

it 'parses method directives that start with multiple hashes' do
source = %(
module Bar
##
# @!method foobar()
# @return [String]
define_method :foobar do
"foobar"
end
end
)
map = Solargraph::SourceMap.load_string(source)
pin = map.first_pin('Bar#foobar')
expect(pin.path).to eq('Bar#foobar')
end
end

0 comments on commit 0077f5c

Please sign in to comment.