YouCompleteMe icon indicating copy to clipboard operation
YouCompleteMe copied to clipboard

Context Free Symbol search: query all open filetypes and merge results

Open puremourning opened this issue 3 years ago • 2 comments

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

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).


This change is Reviewable

puremourning avatar May 04 '21 19:05 puremourning

Codecov Report

Merging #3886 (a145dd9) into master (d35df61) will decrease coverage by 6.41%. The diff coverage is 44.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     

codecov[bot] avatar May 04 '21 19:05 codecov[bot]

I thought using python in the tests would lead to flakiness. Have to think of something else for that.

puremourning avatar May 04 '21 20:05 puremourning

Thanks for sending a PR!

mergify[bot] avatar Aug 17 '22 19:08 mergify[bot]