+9
-13
lines changedFilter options
+9
-13
lines changed Original file line number Diff line number Diff line change
@@ -167,30 +167,31 @@ end
167
167
--- Gets the text corresponding to a given node
168
168
---
169
169
---@param node the node
170
-
---@param bsource The buffer or string from which the node is extracted
170
+
---@param source The buffer or string from which the node is extracted
171
171
function M.get_node_text(node, source)
172
172
local start_row, start_col, start_byte = node:start()
173
173
local end_row, end_col, end_byte = node:end_()
174
174
175
175
if type(source) == "number" then
176
176
local lines
177
-
local eof_row = vim.api.nvim_buf_line_count(source)
177
+
local eof_row = a.nvim_buf_line_count(source)
178
178
if start_row >= eof_row then
179
179
return nil
180
180
end
181
+
181
182
if end_col == 0 then
182
183
lines = a.nvim_buf_get_lines(source, start_row, end_row, true)
183
-
end_col = #lines[#lines]
184
+
end_col = -1
184
185
else
185
186
lines = a.nvim_buf_get_lines(source, start_row, end_row + 1, true)
186
187
end
187
-
lines[1] = string.sub(lines[1], start_col + 1)
188
188
189
-
local end_index = end_col
190
189
if #lines == 1 then
191
-
end_index = end_col - start_col
190
+
lines[1] = string.sub(lines[1], start_col+1, end_col)
191
+
else
192
+
lines[1] = string.sub(lines[1], start_col+1)
193
+
lines[#lines] = string.sub(lines[#lines], 1, end_col)
192
194
end
193
-
lines[#lines] = string.sub(lines[#lines], 1, end_index)
194
195
195
196
return table.concat(lines, "\n")
196
197
elseif type(source) == "string" then
@@ -247,13 +248,8 @@ local predicate_handlers = {
247
248
248
249
return function(match, _, source, pred)
249
250
local node = match[pred[2]]
250
-
local start_row, start_col, end_row, end_col = node:range()
251
-
if start_row ~= end_row then
252
-
return false
253
-
end
254
-
255
251
local regex = compiled_vim_regexes[pred[3]]
256
-
return regex:match_line(source, start_row, start_col, end_col)
252
+
return regex:match_str(M.get_node_text(node, source))
257
253
end
258
254
end)(),
259
255
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4