fix: use window cursor position before getting nvim-navic context #120
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have
show_modified = true
in my config for barbecue, and as I was using it, I noticed that if I had a buffer open in two windows, if I modified the buffer in one of the windows, it wouldn't show as modified in the other window:clip1.mov
The reason for this is because even though I had an auto command to run
require("barbecue.ui").update()
whenBufModifiedSet
is triggered, by default theupdate
function only operates on the current window. So to fix this issue, I tweaked my auto command to make sure it ran theupdate
function on each window that has the buffer:This worked to solve the issue of the mismatching modified signs:
clip2.mov
However, I then noticed the context from
nvim-navic
now was always the same on each window even though the cursor was at different places.The reason for this is because when the
update
function is called, when it gets the context data from navic, navic returns the latest cached entry it has for the target buffer for the current window. In order to fix this problem, we need to make sure to update the navic data according to where the cursor is in the specific window we are getting the context for. This PR does this.Now the modified symbol and context shows properly when I have the same buffer in two windows:
clip3.mov