diff --git a/lib/steep/cli.rb b/lib/steep/cli.rb index 13b0e7410..216bf9e27 100644 --- a/lib/steep/cli.rb +++ b/lib/steep/cli.rb @@ -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 @@ -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. @@ -666,7 +666,7 @@ 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 @@ -674,11 +674,6 @@ def process_query 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 diff --git a/lib/steep/drivers/query.rb b/lib/steep/drivers/query.rb index a71e4b41f..980da3b49 100644 --- a/lib/steep/drivers/query.rb +++ b/lib/steep/drivers/query.rb @@ -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 } } } diff --git a/test/cli_test.rb b/test/cli_test.rb index 34b1f8d7c..ee94e8861 100644 --- a/test/cli_test.rb +++ b/test/cli_test.rb @@ -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 @@ -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