@@ -110,22 +110,10 @@ local get_tree = ts_utils.memoize_by_buf_tick(function(bufnr)
110
110
return tree [1 ]:root ()
111
111
end )
112
112
113
- local function get_predicate_nodes (match , n )
114
- local total = n or 2
115
- local counter = 1
116
- local nodes = {}
117
- for _ , node in pairs (match ) do
118
- nodes [counter ] = node
119
- counter = counter + 1
120
- if counter > total then
121
- break
122
- end
123
- end
124
- return unpack (nodes )
125
- end
113
+ local function is_valid_markup_range (match , _ , source , predicates )
114
+ local start_node = match [predicates [2 ]]
115
+ local end_node = match [predicates [3 ]]
126
116
127
- local function is_valid_markup_range (match , _ , source , _ )
128
- local start_node , end_node = get_predicate_nodes (match )
129
117
if not start_node or not end_node then
130
118
return
131
119
end
@@ -150,8 +138,10 @@ local function is_valid_markup_range(match, _, source, _)
150
138
and end_text :sub (1 , 1 ) ~= ' '
151
139
end
152
140
153
- local function is_valid_hyperlink_range (match , _ , source , _ )
154
- local start_node , end_node = get_predicate_nodes (match )
141
+ local function is_valid_hyperlink_range (match , _ , source , predicates )
142
+ local start_node = match [predicates [2 ]]
143
+ local end_node = match [predicates [3 ]]
144
+
155
145
if not start_node or not end_node then
156
146
return
157
147
end
@@ -171,8 +161,10 @@ local function is_valid_hyperlink_range(match, _, source, _)
171
161
return is_valid_start and is_valid_end
172
162
end
173
163
174
- local function is_valid_latex_range (match , _ , source , _ )
175
- local start_node_left , start_node_right , end_node = get_predicate_nodes (match , 3 )
164
+ local function is_valid_latex_range (match , _ , source , predicates )
165
+ local start_node_left = match [predicates [2 ]]
166
+ local start_node_right = match [predicates [3 ]]
167
+ local end_node = match [predicates [4 ]]
176
168
if not start_node_right or not end_node then
177
169
return
178
170
end
0 commit comments