Skip to content

Commit a74e940

Browse files
PriceHillerNTBBloodbath
authored andcommitted
fix(parser): make parse_request handle request TS nodes
Problem: Placing cursor between a request method and a uri and then invoking `:Rest run` causes the node to be incorrectly parsed leading to an error. See the following where the column above the caret (^) denotes the cursor position: ``` GET https://google.com ^ cursor above caret ``` Running this will cause an error. This is because the `parser.parse_request` method cannot handle Treesitter nodes of type `request`. Solution: Make the `parser.parse_request` function handle Treesitter nodes of type `request` by recursively calling itself on the `request` node and taking that output when it finds a `request` node.
1 parent 272ce95 commit a74e940

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lua/rest-nvim/parser/init.lua

+2
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ function parser.parse_request(children_nodes, variables)
221221
elseif node_type == "http_version" then
222222
local http_version = assert(get_node_text(node, 0))
223223
request.http_version = http_version:gsub("HTTP/", "")
224+
elseif node_type == "request" then
225+
request = parser.parse_request(traverse_request(node), variables)
224226
end
225227
end
226228

0 commit comments

Comments
 (0)