onivim / oni2

Native, lightweight modal code editor
https://v2.onivim.io
MIT License
7.82k stars 278 forks source link

Quick open should favour results closer to the current directory #1831

Open mabuchner opened 4 years ago

mabuchner commented 4 years ago

I'm working with a C++ project which contains many "CMakeLists.txt" files in different sub-directories.

The most relevant "CMakeLists.txt" file is the one at the root of the project. However, if I use quick open and search for "cmakelis", then I get lots of different results from deeply nested directories and entries where only individual characters match. The "CMakeLists.txt" file from the root only appears for a split second directly after typing and after entering more characters ("cmakelists").

To demonstrate the problem, I made two videos. One shows quick open in Onivim2 and the other one show quick open in Sublime Text 3.

quick-open-oni2.mov.zip

quick-open-sublime.mov.zip

"cmakelist" should match "CMakeLists.txt" more than it matches "avalones/libs/ktx/build/CMakeLists.txt".

mabuchner commented 4 years ago

The intermediate results are also vastly different. "cmakeli" produces completely different matches, than "cmakelis".

CrossR commented 4 years ago

Out of curiosity, what size is your repo? As in, how many files? git ls-files | wc -l should be sufficient, since we use ripgrep which respects any .gitignores.

The matching we have right now should already favour the shortest matches (which in turn favours matches at the root), but I have noticed that for some large repos, it feels like the streaming of results messes with the sorting somewhat. I've not looked to see if that is actually possible, so its just anecdotal right now, where I'd see a good result flash up, then be lost under random worse results, as seen in your video.

I'm also working on bringing in https://github.com/jhawthorn/fzy as the matching library, but am hitting some awkward OCaml - C FFI issues, but should hopefully be sorted soon. We will then know for sure its good matching, as well as having a CLI based tool to compare against by running the same ripgrep command outside oni2.

mabuchner commented 4 years ago

I added the --recurse-submodules flag, because we are using submodules.

git ls-files --recurse-submodules | wc -l then returns 9841.

mabuchner commented 4 years ago

I just create a new Unity project with 181 files, which initially wasn't using Git.

If I search for "appcont", then quick open seems to think, that "Library/PackageCache/com.unity.package-manager-ui@2.0.8/Editor/Sources/Services/Common/ApplicationUtil.cs" is a better match, than "Assets/AppController.cs".

Screenshot 2020-05-28 at 11 55 23 AM

After initialising a Git repository I get the expected match as soon as I type "ap".

Screenshot 2020-05-28 at 11 54 59 AM

Maybe that's separate problem, because my C++ project is already using Git.