@@ -110,22 +110,10 @@ local get_tree = ts_utils.memoize_by_buf_tick(function(bufnr)
110110 return tree [1 ]:root ()
111111end )
112112
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 ]]
126116
127- local function is_valid_markup_range (match , _ , source , _ )
128- local start_node , end_node = get_predicate_nodes (match )
129117 if not start_node or not end_node then
130118 return
131119 end
@@ -150,8 +138,10 @@ local function is_valid_markup_range(match, _, source, _)
150138 and end_text :sub (1 , 1 ) ~= ' '
151139end
152140
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+
155145 if not start_node or not end_node then
156146 return
157147 end
@@ -171,8 +161,10 @@ local function is_valid_hyperlink_range(match, _, source, _)
171161 return is_valid_start and is_valid_end
172162end
173163
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 ]]
176168 if not start_node_right or not end_node then
177169 return
178170 end
0 commit comments