YouCompleteMe
YouCompleteMe copied to clipboard
Context Free Symbol search: query all open filetypes and merge results
Sorry this is a pretty big PR. May help to review by commits, as the earlier commits make the underlying changes, and the later commits implement the functional changes.
I frequently found myself wanting to query any part of my current "workspace" irrespective of current context.
In particular, my mental model was of using a "C++ project" but if my cursor was in a config file or script, then the symbol search just wouldn't work. As I said on GItter:
This is the kind of thing where we want it to feel intuitive. In my case about 8/10 times I was working in a c++ project but had say a config file or script open in the current buffer. My “mental model” was that I was working in c++ but I actually was working in, say, TCL at that moment.
So instead we query for each open filetype for which YCM is not blacklisted.
In order for this to feel snappy, we have to be able to request the symbols from multiple filetypes at the same time. This required some changes:
- allow multiple simultaneous command requests. This is not breaking change, as the result was always delivered from a callback. This works by associating an ID with each request and having the poller just check each pending request and call the appropriate one(s). this is way better than a timer-per-request in my testing.
- make the "pending request" part of symbol popup handling recording any filetypes which are "busy" when the query last changed, then sending a new request when responses come in).
- store raw results in a per-filetype map.
Of course, this only applies to the workspace search, not the document search, which naturally context sensitive.
I also added the filetype to the popup window/buffer. This is a little tricky to code due to trying to get the widths right, but looks like this:
![Screenshot-2021-04-30-at-18 12 21](https://user-images.githubusercontent.com/10584846/117061025-97f2ee00-ad19-11eb-8710-42a5f16526b3.png)
Incidentally I have a ycmd change that will make the typescript symbols highlight correctly.
May help to review by commits, as the earlier commits make the underlying changes, and the later commits tell a bit of a story about how this was developed (first dumbly with all requests waiting for each other, then with the more complex pending requests mechanism).
Codecov Report
Merging #3886 (a145dd9) into master (d35df61) will decrease coverage by
6.41%
. The diff coverage is44.82%
.
@@ Coverage Diff @@
## master #3886 +/- ##
==========================================
- Coverage 89.49% 83.08% -6.42%
==========================================
Files 29 25 -4
Lines 3913 2500 -1413
==========================================
- Hits 3502 2077 -1425
- Misses 411 423 +12
I thought using python in the tests would lead to flakiness. Have to think of something else for that.
Thanks for sending a PR!