We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
search_ancestors
1 parent 26c7e82 commit 6cf5fceCopy full SHA for 6cf5fce
lua/quarto/util.lua
@@ -15,6 +15,27 @@ function M.strip_archive_subpath(path)
15
return path
16
end
17
18
+function M.search_ancestors(startpath, func)
19
+ if nvim_eleven then
20
+ vim.validate('func', func, 'function')
21
+ end
22
+ if func(startpath) then
23
+ return startpath
24
25
+ local guard = 100
26
+ for path in vim.fs.parents(startpath) do
27
+ -- Prevent infinite recursion if our algorithm breaks
28
+ guard = guard - 1
29
+ if guard == 0 then
30
+ return
31
32
+
33
+ if func(path) then
34
+ return path
35
36
37
+end
38
39
local function escape_wildcards(path)
40
return path:gsub('([%[%]%?%*])', '\\%1')
41
0 commit comments