Skip to content
Open
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
11 changes: 3 additions & 8 deletions lib/steep/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def process_query
--help Show this help message

Examples:
steep query hover lib/foo.rb:10:5
steep query hover lib/foo.rb:9:4
steep query definition RBS::Location
steep query definition RBS::Parser.parse_signature
HELP
Expand All @@ -643,7 +643,7 @@ def process_query
Connects to the running Steep daemon and returns type information as JSONL
(one JSON object per line for each queried position).

FILE:LINE:COL - File path with 1-based line and column numbers.
FILE:LINE:COL - File path with 0-based line and column numbers (LSP convention).

Note:
This is an experimental command.
Expand All @@ -666,19 +666,14 @@ def process_query
match = location.match(/\A(.+):(\d+):(\d+)\z/)
unless match
stderr.puts "Error: Invalid format: #{location}"
stderr.puts " Expected format: FILE:LINE:COL (e.g., lib/foo.rb:10:5)"
stderr.puts " Expected format: FILE:LINE:COL (e.g., lib/foo.rb:9:4)"
return 1
end

path = match[1] or raise
line = match[2].to_i
column = match[3].to_i

if line < 1 || column < 1
stderr.puts "Error: LINE and COL must be positive integers (1-based)"
return 1
end

locations << [path, line, column]
end

Expand Down
2 changes: 1 addition & 1 deletion lib/steep/drivers/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def run_hover(locations:)
method: "textDocument/hover",
params: {
textDocument: { uri: uri },
position: { line: line - 1, character: column - 1 }
position: { line: line, character: column }
}
}

Expand Down
8 changes: 4 additions & 4 deletions test/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1017,13 +1017,13 @@ def test_query_hover_returns_result

begin
finally_holds(timeout: 30) do
stdout, status = sh(*steep, "query", "hover", "foo.rb:2:1")
stdout, status = sh(*steep, "query", "hover", "foo.rb:1:0")
assert_predicate status, :success?

result = JSON.parse(stdout.lines.first, symbolize_names: true)
assert_equal "foo.rb", result[:file]
assert_equal 2, result[:line]
assert_equal 1, result[:column]
assert_equal 1, result[:line]
assert_equal 0, result[:column]
assert result[:result], "Expected hover result"
end
ensure
Expand Down Expand Up @@ -1051,7 +1051,7 @@ def test_query_hover_multiple_locations

begin
finally_holds(timeout: 30) do
stdout, status = sh(*steep, "query", "hover", "foo.rb:2:1", "foo.rb:2:5")
stdout, status = sh(*steep, "query", "hover", "foo.rb:1:0", "foo.rb:1:4")
assert_predicate status, :success?

lines = stdout.lines
Expand Down
Loading