@@ -72,28 +72,18 @@ local get_query_matches = memoize(function(bufnr, query_group, root, root_lang)
7272 local matches = {}
7373 local start_row , _ , end_row , _ = root :range ()
7474 -- The end row is exclusive so we need to add 1 to it.
75- for pattern , match , metadata in query :iter_matches (root , bufnr , start_row , end_row + 1 ) do
76- if pattern then
77- local prepared_match = {}
78-
79- -- Extract capture names from each match
80- for id , nodes in pairs (match ) do
81- local query_name = query .captures [id ] -- name of the capture in the query
82- if query_name ~= nil then
83- local path = vim .split (query_name , " %." )
84- if metadata [id ] and metadata [id ].range then
85- insert_to_path (prepared_match , path , add_bytes (bufnr , metadata [id ].range ))
86- else
87- local srow , scol , sbyte , erow , ecol , ebyte = nodes [1 ]:range (true )
88- if # nodes > 1 then
89- local _ , _ , _ , e_erow , e_ecol , e_ebyte = nodes [# nodes ]:range (true )
90- erow = e_erow
91- ecol = e_ecol
92- ebyte = e_ebyte
93- end
94- insert_to_path (prepared_match , path , { srow , scol , sbyte , erow , ecol , ebyte })
95- end
96- end
75+ for id , node , metadata in query :iter_captures (root , bufnr , start_row , end_row + 1 ) do
76+ local prepared_match = {}
77+
78+ -- Extract capture names from each match
79+ local query_name = query .captures [id ] -- name of the capture in the query
80+ if query_name ~= nil then
81+ local path = vim .split (query_name , " %." )
82+
83+ if metadata [id ] and metadata [id ].range then
84+ insert_to_path (prepared_match , path , add_bytes (bufnr , metadata [id ].range ))
85+ else
86+ insert_to_path (prepared_match , path , { node :range (true ) })
9787 end
9888
9989 matches [# matches + 1 ] = prepared_match
0 commit comments