Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .standard.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby_version: 2.5.9
ruby_version: 3.0.0
8 changes: 4 additions & 4 deletions lib/syntax_suggest/clean_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def join_heredoc!
#
def join_consecutive!
consecutive_groups = @document.select(&:ignore_newline_not_beg?).map do |code_line|
take_while_including(code_line.index..-1) do |line|
take_while_including(code_line.index..) do |line|
line.ignore_newline_not_beg?
end
end
Expand All @@ -245,7 +245,7 @@ def join_consecutive!
# expect(lines[1].to_s).to eq("")
def join_trailing_slash!
trailing_groups = @document.select(&:trailing_slash?).map do |code_line|
take_while_including(code_line.index..-1) { |x| x.trailing_slash? }
take_while_including(code_line.index..) { |x| x.trailing_slash? }
end
join_groups(trailing_groups)
self
Expand Down Expand Up @@ -279,7 +279,7 @@ def join_groups(groups)
)

# Hide the rest of the lines
lines[1..-1].each do |line|
lines[1..].each do |line|
# The above lines already have newlines in them, if add more
# then there will be double newline, use an empty line instead
@document[line.index] = CodeLine.new(line: "", index: line.index, lex: [])
Expand All @@ -293,7 +293,7 @@ def join_groups(groups)
# Like `take_while` except when it stops
# iterating, it also returns the line
# that caused it to stop
def take_while_including(range = 0..-1)
def take_while_including(range = 0..)
take_next_and_stop = false
@document[range].take_while do |line|
next if take_next_and_stop
Expand Down
2 changes: 1 addition & 1 deletion lib/syntax_suggest/lex_all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(source:, source_lines: nil)
last_lineno = source_lines.length

until lineno >= last_lineno
lines = source_lines[lineno..-1]
lines = source_lines[lineno..]

@lex.concat(
Ripper::Lexer.new(lines.join, "-", lineno + 1).parse.sort_by(&:pos)
Expand Down
2 changes: 1 addition & 1 deletion lib/syntax_suggest/scan_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def lines
# Returns an array of all the CodeLines that exist after
# the currently scanned block
private def after_lines
@code_lines[@after_index.next..-1] || []
@code_lines[@after_index.next..] || []
end

private def current
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/capture_code_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def call # 0
code_lines = CleanDocument.new(source: source).call.lines

code_lines[0..75].each(&:mark_invisible)
code_lines[77..-1].each(&:mark_invisible)
code_lines[77..].each(&:mark_invisible)
expect(code_lines.join.strip).to eq("class Lookups")

block = CodeBlock.new(lines: code_lines[76..149])
Expand Down Expand Up @@ -123,7 +123,7 @@ def bark

code_lines = CleanDocument.new(source: source).call.lines
block = CodeBlock.new(lines: code_lines)
code_lines[1..-1].each(&:mark_invisible)
code_lines[1..].each(&:mark_invisible)

expect(block.to_s.strip).to eq("class Dog")

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/clean_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module SyntaxSuggest
code_lines = doc.lines

expect(code_lines[0].to_s.count($/)).to eq(5)
code_lines[1..-1].each do |line|
code_lines[1..].each do |line|
expect(line.to_s.strip.length).to eq(0)
end
end
Expand Down