pechorin / any-jump.vim

Jump to any definition and references 👁 IDE madness without overhead 🚀
1.07k stars 40 forks source link

Crash/Hang when Running from Large Directory #93

Open conor-f opened 3 years ago

conor-f commented 3 years ago

I opened a file in a distant subdirectory today without cding into it:

cd
vim Code/example-project/src/example-package/file.py

and :AnyJump hung in a way that was difficult to exit. I presume this is because it was running the search from ~/ instead of looking specifically within subdirectories? I imagine there could be some bit of optimization made where it could recursively look in directories back from the current file path. e.g. from the example above, searching in the order:

Code/example-project/src/example-package/*
Code/example-project/src/*
Code/example-project/*
Code/*
*

Combined with a max timeout or similar, this would mitigate the issue I think?

midrare commented 1 year ago

Alternatively, we could limit the search area to only files in the current buffer's codebase.

We can do this by traveling up the directory tree, starting from %:p:h and ending with /, looking for "project root marker" files, e.g. .git, .svn, .root, _darcs, etc. Then once we find the root directory for the project, recursively search only that directory.

If no root markers are found, then it's not a codebase and shouldn't be searched (or only search the directory containing the file associated to the buffer).