Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
SyntaxSuggest::CleanDocument#join_consecutive!
join_consecutive!
lib/syntax_suggest/clean_document.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/syntax_suggest/clean_document.rb, line 225
def join_consecutive!
consecutive_groups = @document.select(&:ignore_newline_not_beg?).map do |code_line|
take_while_including(code_line.index..) do |line|
line.ignore_newline_not_beg?
end
end
join_groups(consecutive_groups)
self
end
Smushes logically “consecutive” lines
Example
source = <<~'EOM' User. where(name: 'schneems'). first EOM lines = CleanDocument.new(source: source).join_consecutive!.lines expect(lines[0].to_s).to eq(source) expect(lines[1].to_s).to eq("")
The one known case this doesn’t handle is:
Example
Ripper.lex <<~EOM a && b || c EOM
For some reason this introduces on_ignore_newline but with BEG type