@@ -119,36 +119,6 @@ local transform = {
119
119
utils .transform_time = transform .time
120
120
utils .transform_size = transform .size
121
121
122
- --- Highlight a request
123
- --- @param bufnr number Buffer handler ID
124
- --- @param start number Request tree-sitter node start
125
- --- @param end_ number Request tree-sitter node end
126
- --- @param ns number rest.nvim Neovim namespace
127
- function utils .highlight (bufnr , start , end_ , ns )
128
- local highlight = _G ._rest_nvim .highlight
129
- local higroup = " IncSearch"
130
- local timeout = highlight .timeout
131
-
132
- -- Clear buffer highlights
133
- vim .api .nvim_buf_clear_namespace (bufnr , ns , 0 , - 1 )
134
-
135
- -- Highlight request
136
- vim .highlight .range (
137
- bufnr ,
138
- ns ,
139
- higroup ,
140
- { start , 0 },
141
- { end_ , string.len (vim .fn .getline (end_ )) }
142
- )
143
-
144
- -- Clear buffer highlights again after timeout
145
- vim .defer_fn (function ()
146
- if vim .api .nvim_buf_is_valid (bufnr ) then
147
- vim .api .nvim_buf_clear_namespace (bufnr , ns , 0 , - 1 )
148
- end
149
- end , timeout )
150
- end
151
-
152
122
--- @param bufnr number
153
123
--- @param node TSNode
154
124
--- @param ns number
@@ -160,6 +130,11 @@ function utils.ts_highlight_node(bufnr, node, ns)
160
130
local higroup = " IncSearch"
161
131
local s_row , s_col = node :start ()
162
132
local e_row , e_col = node :end_ ()
133
+ -- don't try to highlight over the last line
134
+ if e_col == 0 then
135
+ e_row = e_row - 1
136
+ e_col = - 1
137
+ end
163
138
vim .highlight .range (
164
139
bufnr ,
165
140
ns ,
@@ -187,7 +162,7 @@ function utils.ts_parse_source(source)
187
162
else
188
163
ts_parser = vim .treesitter .get_parser (source , " http" )
189
164
end
190
- return ts_parser , assert (ts_parser :parse ({} )[1 ])
165
+ return ts_parser , assert (ts_parser :parse (false )[1 ])
191
166
end
192
167
193
168
--- @param node TSNode
0 commit comments