Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
SyntaxSuggest::AroundBlockScan#scan_adjacent_indent
scan_adjacent_indent
lib/syntax_suggest/around_block_scan.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/syntax_suggest/around_block_scan.rb, line 200
def scan_adjacent_indent
before_after_indent = []
before_after_indent << (@scanner.next_up&.indent || 0)
before_after_indent << (@scanner.next_down&.indent || 0)
@target_indent = before_after_indent.min
scan_while { |line| line.not_empty? && line.indent >= @target_indent }
self
end
Scan blocks based on indentation of next line above/below block
Determines indentaion of the next line above/below the current block.
Normally this is called when a block has expanded to capture all “neighbors” at the same (or greater) indentation and needs to expand out. For example the def/end lines surrounding a method.
See also
#lookahead_balance_one_line
#scan_neighbors_not_empty
#lines
#scan_while
also in
4.0 · 3.3 · 3.2