This isn't a treesitter solution, but it's at least a quick and easy, if only temporary, patch.
start_request was searching forward from the cursor position. Adding 'b' to the search flags fixed that.
Both start_request and end_request depended on the user having set 'nowrapscan' to prevent wrapping around the end of the file. Such wrapping could result in finding the wrong query. Adding 'W' to the search flags fixed that, and removed the need for the stopline parameter.
Refactored the way last_line is used in end_request.
Fixes #173.
This isn't a treesitter solution, but it's at least a quick and easy, if only temporary, patch.