This repository was archived by the owner on May 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,7 @@ M.get_all_entries = function()
180180 return entries
181181end
182182
183+ -- if we have a pattern to search for, only consider lines after the pattern
183184M .filter_doc = function (lines , pattern )
184185 if not pattern then return lines end
185186
@@ -188,16 +189,17 @@ M.filter_doc = function(lines, pattern)
188189
189190 local filtered_lines = {}
190191 local found = false
191- local search_pattern = create_pattern (pattern )
192+ local pattern_lines = vim .split (pattern , " \n " )
193+ local search_pattern = create_pattern (pattern_lines [1 ]) -- only search the first line
192194 local split = vim .split (pattern , " " )
193195 local header = split [1 ]
194196 local top_header = header and header :sub (1 , # header - 1 )
195197
196198 for _ , line in ipairs (lines ) do
197- if found and header then
199+ if found then
198200 local line_split = vim .split (line , " " )
199201 local first = line_split [1 ]
200- if first and first == header or first == top_header then break end
202+ if first == header or first == top_header then break end
201203 end
202204 if line :match (search_pattern ) then found = true end
203205 if found then table.insert (filtered_lines , line ) end
You can’t perform that action at this time.
0 commit comments