Skip to content

ale: add FindNearestFileOrDirectory function#5033

Merged
w0rp merged 2 commits intodense-analysis:masterfrom
mathstuf:find-nearest-file-or-dir
Aug 21, 2025
Merged

ale: add FindNearestFileOrDirectory function#5033
w0rp merged 2 commits intodense-analysis:masterfrom
mathstuf:find-nearest-file-or-dir

Conversation

@mathstuf
Copy link
Contributor

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.


Cc: @rymdbar

@mathstuf
Copy link
Contributor Author

If this API is suitable, I'll add commits to migrate .git searching to use this to improve git worktree support ALE-wide. Separate commits should help bisection/reverting for anything that it causes problems for (e.g., the tool itself doesn't properly support worktrees).

@mathstuf mathstuf force-pushed the find-nearest-file-or-dir branch from 23c59e0 to 6b1cbc5 Compare August 19, 2025 01:51
It matches the API name better and now lives beside the test file for
`FindNearestDirectory`.
@mathstuf mathstuf force-pushed the find-nearest-file-or-dir branch 4 times, most recently from d144ada to 6ad4b81 Compare August 19, 2025 13:49
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.
@mathstuf mathstuf force-pushed the find-nearest-file-or-dir branch from 6ad4b81 to d662844 Compare August 19, 2025 13:59
@mathstuf mathstuf marked this pull request as ready for review August 19, 2025 14:02
Copy link
Member

@w0rp w0rp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me and I see the need for it. Cheers! 🍻

@w0rp w0rp merged commit 528e259 into dense-analysis:master Aug 21, 2025
8 checks passed
@mathstuf mathstuf deleted the find-nearest-file-or-dir branch August 21, 2025 14:02
@rymdbar
Copy link
Contributor

rymdbar commented Aug 31, 2025

Cc: @rymdbar

Apologies for the delay looking at this. Looks good to me, and apparently to w0rp too.

I ran grep and navigated the sources a bit, pushed #5038 and created #5039. Would you still be up for going through the list of tools and adapt them to use your new function? I might have a go at a few more of the tools I'm actively using.

Somewhat related, I also filed #5040 which is more of an idea than something I'm sure anyone (me included) is fully committed to.

Caw3 pushed a commit to Caw3/ale that referenced this pull request Dec 10, 2025
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants