-
-
Notifications
You must be signed in to change notification settings - Fork 623
fix(#2519): Diagnostics Not Updated When Tree Not Visible #2597
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
Conversation
I've just noticed that fetching diagnostics with coc is completely broken when setting The current implementation will find the highest severity, then discard items that are out of range. Now, the lsp and coc functions look pretty much the same, which makes sense, as there's no big difference between the two, except that with coc we have to bother about the severity limit of each item. The commit that introduced this bug: 874b7be. |
Signed-off-by: iusmac <iusico.maxim@libero.it>
Also, while we're at it, refactor the lsp function for consistency. There should be no functional change, just cosmetic. Signed-off-by: iusmac <iusico.maxim@libero.it>
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.
This is looking great - many thanks for dealing with the regressive behaviour.
|
||
---@param path string | ||
---@return string | ||
local function uniformize_path(path) |
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.
Nice name!
lua/nvim-tree/renderer/builder.lua
Outdated
@@ -413,6 +413,8 @@ end | |||
function Builder:_build_line(node, idx, num_children, unloaded_bufnr) | |||
local copy_paste = require "nvim-tree.actions.fs.copy-paste" | |||
|
|||
require("nvim-tree.diagnostics").update_node_severity_level(node) |
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.
This one is very concerning from a performance perspective; we go out of our way to avoid such calls on drawing each line.
Could we improve via one of:
- do this once for all nodes prior to rendering
- short-circuit this so that it's only called when there is no diagnostic info
log.node("diagnostics", buffer_severity_dict, "update") | ||
log.profile_end(profile) | ||
if view.is_buf_valid(view.get_bufnr()) then | ||
require("nvim-tree.renderer").draw() |
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.
/ nit please require once at the start of the file
lua/nvim-tree/diagnostics.lua
Outdated
if is_using_coc() then | ||
buffer_severity = from_coc() | ||
buffer_severity_dict = from_coc() |
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.
/ nit no dict please - we're not writing python here ;)
Signed-off-by: iusmac <iusico.maxim@libero.it>
Signed-off-by: iusmac <iusico.maxim@libero.it>
Causes circular requires after the previous commit. This reverts commit 7413041.
Signed-off-by: iusmac <iusico.maxim@libero.it>
Signed-off-by: iusmac <iusico.maxim@libero.it>
Signed-off-by: iusmac <iusico.maxim@libero.it>
While we're at it, implement error handling for coc.nvim. If you're lucky and hit
|
lua/nvim-tree/diagnostics.lua
Outdated
|
||
--- The buffer-severity mappings derived during the last diagnostic list update. | ||
---@type table | ||
local BUFFER_SEVERITY = {} |
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.
This is looking good; we have a cache similar to git's.
It'll take me a while to properly review and test this one.
Signed-off-by: iusmac <iusico.maxim@libero.it>
Signed-off-by: iusmac <iusico.maxim@libero.it>
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.
Looks great, works well.
I did not test COC. In the unlikely event of any issues I'll call on you ;)
Added some doc and some minor tidies.
Many thanks for all your work!
local log = require "nvim-tree.log" | ||
|
||
local M = {} | ||
|
||
local severity_levels = { | ||
---TODO add "$VIMRUNTIME" to "workspace.library" and use the @enum instead of this integer |
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.
That one's a work in progress #2546
The diagnostic changed event has been untied from the current tree state to ensure the data availability at any time. Now, the diagnostics will be picked up "on the fly" whenever the tree is about to be (re-)drawn, which makes absolute sense, especially, when incrementally exploring the file system structure or when (re-)opening the tree and the diagnostic changed event has already occurred.
All in all, this effectively solves any inconsistencies (see #2517), and ensures that the tree shows the freshest diagnostics, regardless of the tree's state and when diagnostics change.