New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[READY] Use location list stack, instead of trampling on existing ones #3951
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3951 +/- ##
==========================================
- Coverage 91.43% 91.18% -0.25%
==========================================
Files 27 27
Lines 3688 3699 +11
==========================================
+ Hits 3372 3373 +1
- Misses 316 326 +10 |
c45fa0e
to
8f87bb7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 2 LGTMs obtained (waiting on @bstaletic and @puremourning)
a discussion (no related file):
So I found a case which maybe isn't quite what we might expect:
- open a file with no errors
:lgrep something
to create loc list- create an error
:lwindow
(see the YCM errors):lolder
(see the grep results)- create another error
- Expect: still see the grep results
- Actual: the YCM loc list is visible.
intentional?
python/ycm/vimsupport.py, line 323 at r1 (raw file):
total_location_lists = int( vim.eval( f'getloclist( { window_number}, ' '{ "nr": "$" } ).nr' ) ) ycm_loc_id = None
maybe we could just store this in the window as a variable like vim.windows[ window_number ].variables[ 'ycm_loc_id' ], this is the equivalent of let w:ycm_loc_id =
and saves all this searching. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 2 LGTMs obtained (waiting on @puremourning)
a discussion (no related file):
Hm... What was your g:ycm_always_populate_location_list
and g:ycm_open_locationlist_on_ycm_diags
?
With both set to 1
I don't see that behaviour.
- open a file with no errors
- :lgrep something to create loc list
The location list window already opens for me. Closing.
- create an error
:lwindow
(see the YCM errors)
Uhm... I still see :lgrep
results.
:lolder
(see the grep results)
Returns me to YCM error list!
- create another error
- Expect: still see the grep results.
Works on my machine!
python/ycm/vimsupport.py, line 323 at r1 (raw file):
Previously, puremourning (Ben Jackson) wrote…
maybe we could just store this in the window as a variable like vim.windows[ window_number ].variables[ 'ycm_loc_id' ], this is the equivalent of
let w:ycm_loc_id =
and saves all this searching. wdyt?
I tried to break it, but so far couldn't. Should get some dogfooding treatment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 8 files at r1, all commit messages.
Reviewable status: 1 of 2 LGTMs obtained (waiting on @puremourning)
a discussion (no related file):
Previously, bstaletic (Boris Staletic) wrote…
Hm... What was your
g:ycm_always_populate_location_list
andg:ycm_open_locationlist_on_ycm_diags
?With both set to
1
I don't see that behaviour.
- open a file with no errors
- :lgrep something to create loc list
The location list window already opens for me. Closing.
- create an error
:lwindow
(see the YCM errors)Uhm... I still see
:lgrep
results.
:lolder
(see the grep results)Returns me to YCM error list!
- create another error
- Expect: still see the grep results.
Works on my machine!
Hmm both set to 1 for me.
Also, I can't seem to repro now either. Maybe I was confused the other day.
do we need to update anything in the README ?
python/ycm/vimsupport.py, line 323 at r1 (raw file):
Previously, bstaletic (Boris Staletic) wrote…
I tried to break it, but so far couldn't. Should get some dogfooding treatment.
I don't think this is broken, just inelegant. not a big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 8 files at r1.
Reviewable status: 1 of 2 LGTMs obtained (waiting on @bstaletic)
8f87bb7
to
2163ff0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 2 LGTMs obtained (and 1 stale) (waiting on @puremourning)
a discussion (no related file):
do we need to update anything in the README ?
I added a small note.
python/ycm/vimsupport.py, line 323 at r1 (raw file):
Previously, puremourning (Ben Jackson) wrote…
I don't think this is broken, just inelegant. not a big deal.
I forgot to push yesterday. Anyway, implemented what you've asked for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 7 of 7 files at r2, all commit messages.
Reviewable status: 1 of 2 LGTMs obtained (waiting on @bstaletic)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet! Nice.
Reviewable status: 1 of 2 LGTMs obtained (waiting on @bstaletic)
Thanks for sending a PR! |
PR Prelude
Thank you for working on YCM! :)
Please complete these steps and check these boxes (by putting an
x
insidethe brackets) before filing your PR:
rationale for why I haven't.
actually perform all of these steps.
Why this change is necessary and useful
Personally, I wanted this for a looong time, but the first time I brought this up @puremourning was against it. The argument was that it would be too advanced for an average vim user to navigate the loclist stack. The other reason this wasn't implemented earlier is because the docs are really not clear how the finer details of
setloclist()
work!But here's the general idea:
:lgrep
, we don't want to instantly trample over that location list. So we need a different one in the stack.:Nlolder
?5.1. There are two relevant options:
g:ycm_always_populate_location_list
andg:ycm_open_loclist_on_ycm_diags
5.2. If the former is off and latter on, populating only happens manually and makes cursor focus the loc list.
5.3. If both are off, even
:YcmDiags
won't show the list.5.4. If former is on, but latter is off, both automatic population and
:YcmDiags
will populate the loc list, but we'll never open it for the user.5.5. If both are on, both ways populate the loc list, but only
:YcmDiags
makes YCM focus the loc list.5
is defined like that, because visiting a buffer for which filetype there's no diagnostics available at all, we should never replace:lgrep
with an empty list of diags. Ever.The PR, as is, seems to be working with clangd at least. Testing with something like Tern or libclang would be useful. Writing tests as well.
This will actually make me turn on
g:ycm_always_populate_location_list
.[Please explain in detail why the changes in this PR are needed.]
This change is