summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/syntax_suggest/around_block_scan.rb22
-rw-r--r--lib/syntax_suggest/capture_code_context.rb1
-rw-r--r--spec/syntax_suggest/integration/syntax_suggest_spec.rb4
-rw-r--r--spec/syntax_suggest/unit/capture_code_context_spec.rb5
-rw-r--r--spec/syntax_suggest/unit/display_invalid_blocks_spec.rb2
5 files changed, 7 insertions, 27 deletions
diff --git a/lib/syntax_suggest/around_block_scan.rb b/lib/syntax_suggest/around_block_scan.rb
index 656246c0af..fe63470dee 100644
--- a/lib/syntax_suggest/around_block_scan.rb
+++ b/lib/syntax_suggest/around_block_scan.rb
@@ -176,7 +176,7 @@ module SyntaxSuggest
break
end
- lines << line
+ lines << line if line.is_kw? || line.is_end?
end
lines.reverse!
@@ -195,7 +195,7 @@ module SyntaxSuggest
break
end
- lines << line
+ lines << line if line.is_kw? || line.is_end?
end
lines
@@ -319,24 +319,6 @@ module SyntaxSuggest
self
end
- # TODO: Doc or delete
- #
- # I don't remember why this is needed, but it's called in code_context.
- # It's related to the implementation of `capture_neighbor_context` somehow
- # and that display improvement is only triggered when there's one visible line
- #
- # I think the primary purpose is to not include the current line in the
- # logic evaluation of `capture_neighbor_context`. If that's true, then
- # we should fix that method to handle this logic instead of only using
- # it in one place and together.
- def start_at_next_line
- before_index
- after_index
- @before_index -= 1
- @after_index += 1
- self
- end
-
# Return the currently matched lines as a `CodeBlock`
#
# When a `CodeBlock` is created it will gather metadata about
diff --git a/lib/syntax_suggest/capture_code_context.rb b/lib/syntax_suggest/capture_code_context.rb
index 547072e2bd..a618b2ec68 100644
--- a/lib/syntax_suggest/capture_code_context.rb
+++ b/lib/syntax_suggest/capture_code_context.rb
@@ -116,7 +116,6 @@ module SyntaxSuggest
return unless block.visible_lines.count == 1
around_lines = AroundBlockScan.new(code_lines: @code_lines, block: block)
- .start_at_next_line
.capture_neighbor_context
around_lines -= block.lines
diff --git a/spec/syntax_suggest/integration/syntax_suggest_spec.rb b/spec/syntax_suggest/integration/syntax_suggest_spec.rb
index bb50fafce7..f1ceac23c5 100644
--- a/spec/syntax_suggest/integration/syntax_suggest_spec.rb
+++ b/spec/syntax_suggest/integration/syntax_suggest_spec.rb
@@ -115,9 +115,6 @@ module SyntaxSuggest
expect(io.string).to include(<<~'EOM')
5 module DerailedBenchmarks
6 class RequireTree
- 7 REQUIRED_BY = {}
- 9 attr_reader :name
- 10 attr_writer :cost
> 13 def initialize(name)
> 18 def self.reset!
> 25 end
@@ -160,7 +157,6 @@ module SyntaxSuggest
out = io.string
expect(out).to include(<<~EOM)
16 class Rexe
- 18 VERSION = '1.5.1'
> 77 class Lookups
> 140 def format_requires
> 148 end
diff --git a/spec/syntax_suggest/unit/capture_code_context_spec.rb b/spec/syntax_suggest/unit/capture_code_context_spec.rb
index e1bc281c13..1563149b3c 100644
--- a/spec/syntax_suggest/unit/capture_code_context_spec.rb
+++ b/spec/syntax_suggest/unit/capture_code_context_spec.rb
@@ -16,13 +16,14 @@ module SyntaxSuggest
EOM
code_lines = CleanDocument.new(source: source).call.lines
- block = CodeBlock.new(lines: code_lines[0])
+ block = CodeBlock.new(lines: code_lines[3])
display = CaptureCodeContext.new(
blocks: [block],
code_lines: code_lines
)
- lines = display.call
+
+ lines = display.capture_before_after_kws(block).sort
expect(lines.join).to eq(<<~'EOM')
def sit
end
diff --git a/spec/syntax_suggest/unit/display_invalid_blocks_spec.rb b/spec/syntax_suggest/unit/display_invalid_blocks_spec.rb
index 2c59d9dc78..b11d7d242e 100644
--- a/spec/syntax_suggest/unit/display_invalid_blocks_spec.rb
+++ b/spec/syntax_suggest/unit/display_invalid_blocks_spec.rb
@@ -144,6 +144,7 @@ module SyntaxSuggest
expect(io.string).to include([
" 1 class OH",
"> 2 def hello",
+ " 3 def hai",
" 4 end",
" 5 end",
""
@@ -162,6 +163,7 @@ module SyntaxSuggest
[
" 1 class OH",
["> 2 ", DisplayCodeWithLineNumbers::TERMINAL_HIGHLIGHT, " def hello"].join,
+ " 3 def hai",
" 4 end",
" 5 end",
""