mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-20 00:28:35 +08:00
ale: add FindNearestFileOrDirectory function (#5033)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
* test: rename `FindNearestFile` test file It matches the API name better and now lives beside the test file for `FindNearestDirectory`. * ale: add `FindNearestFileOrDirectory` function Some anchor paths can be files or directories (e.g., `.git` is a directory normally, but a file for worktrees). Add a function that finds either type of path and returns the nearest.
This commit is contained in:
15
test/test_find_nearest_file.vader
Normal file
15
test/test_find_nearest_file.vader
Normal file
@@ -0,0 +1,15 @@
|
||||
Before:
|
||||
call ale#test#SetDirectory('/testplugin/test')
|
||||
|
||||
After:
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(We should be able to find a configuration file further up):
|
||||
call ale#test#SetFilename('test-files/top/middle/bottom/dummy.txt')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(expand('%:p:h:h:h:h:h') . '/test-files/top/example.ini'),
|
||||
\ ale#path#FindNearestFile(bufnr('%'), 'example.ini')
|
||||
|
||||
Execute(We shouldn't find anything for files which don't match):
|
||||
AssertEqual '', ale#path#FindNearestFile(bufnr('%'), 'cantfindthis')
|
||||
Reference in New Issue
Block a user