neovim/runtime
Chris AtLee e55e80d51c
fix(lsp): inlay hints: "Failed to delete autocmd" when closing buffer #24469
Problem:
"Failed to delete autocmd" error when deleting LspNotify autocmd. #24456

Solution:
Change a few things in the inlay_hint and diagnostic LSP code:
1. Re-introduce the `enabled` flag for the buffer state tables. Previously I was
   relying on the presence of an autocmd id in the state table to track whether
   inlay_hint / diagnostic was enabled for a buffer. There are two reasons why
   this doesn't work well:
  - Each time inlay_hint / diagnostic is enabled, we call `nvim_buf_attach` on
    the buffer, resulting in multiple `on_reload` or `on_detach` callbacks being
    registered.
  - Commands like `bwipeout` delete buffer local autocmds, sometimes before our
    `on_detach` callbacks have a chance to delete them first. This causes the
  - Use module local enabled state for diagnostic as well. bwipeout can race
    with on_detach callbacks for deleting autocmds. Error referenced in #24456.
2. Change the `LspDetach` autocmd to run each time (i.e., remove the `once`
   flag). Since we're only registering autocmds once per buffer now, we
   need to make sure that we set the enabled flag properly each time the LSP
   client detaches from the buffer.
  - Remove `once` from the LspDetach autocmds for inlay_hint and diagnostic.
    We only set up the autocmd once now. Gets removed when buffer is deleted.
3. Have the `LspNotify` handler also refresh the inlay_hint / diagnostics when
   receiving the `textDocument/didOpen` event. Before this point, the LSP
   backend doesn't have the contents of the buffer, so can't provide inlay hints
   or diagnostics.

Downsides of this approach:
* When inlay_hint / diagnostics are disabled on a buffer, it will continue to
  receive `LspNotify` events for that buffer. The callback exits early since the
  `enabled` flag is false.

Alternatives:
* Can we wrap the call to `nvim_del_autocmd` in `pcall` to swallow any errors
  resulting from trying to delete the autocmd?

Fixes #24456

Helped-by: Maria José Solano <majosolano99@gmail.com>
2023-08-01 05:13:52 -07:00
..
autoload fix(clipboard): ignore exit caused by signal #23378 2023-07-16 04:15:30 -07:00
colors vim-patch:71badf9547e8 (#23285) 2023-04-23 15:22:55 +02:00
compiler vim-patch:86b4816766d9 (#21314) 2022-12-08 16:33:38 +01:00
doc docs(builtin): right align tags (#24522) 2023-08-01 11:12:00 +01:00
ftplugin vim-patch:10e8ff9b2607 (#23977) 2023-06-11 12:40:22 +01:00
indent vim-patch:9.0.1580: CI: indent test hangs on FreeBSD (#23768) 2023-05-26 22:13:42 +08:00
keymap
lua fix(lsp): inlay hints: "Failed to delete autocmd" when closing buffer #24469 2023-08-01 05:13:52 -07:00
macros
pack/dist/opt vim-patch:9.0.1671: Termdebug: error with more than 99 breakpoints (#24194) 2023-06-29 07:04:46 +08:00
plugin fix(gx): move to to _init_default_mappings #24420 2023-07-24 08:35:19 -07:00
queries build(deps): bump tree-sitter-c to v0.20.4 (#24495) 2023-07-27 12:45:08 +02:00
spell feat(runtime): import cleanadd.vim from Vim (#17699) 2022-03-13 04:52:45 +00:00
syntax fix(editorconfig): highlight properties with dashes (#24407) 2023-07-27 14:39:05 +02:00
tools vim-patch:e80086446cc2 (#19848) 2022-08-20 10:04:55 +02:00
tutor fix(tutor): don't use concealed text in expected lines #24316 2023-07-11 10:09:44 -07:00
CMakeLists.txt refactor(build): move the last generator from scripts/ to src/nvim/generators 2023-04-21 16:46:35 +02:00
delmenu.vim vim-patch:9.0.0141: "delmenu" does not remove autocmmands (#19646) 2022-08-05 12:23:41 +02:00
filetype.lua fix(runtime): respect 'rtp' order for all runtime files (#24335) 2023-07-14 06:46:16 +08:00
ftoff.vim
ftplugin.vim fix(runtime): respect 'rtp' order for all runtime files (#24335) 2023-07-14 06:46:16 +08:00
ftplugof.vim
indent.vim fix(runtime): respect 'rtp' order for all runtime files (#24335) 2023-07-14 06:46:16 +08:00
indoff.vim
macmap.vim
makemenu.vim
menu.vim vim-patch:b7398fe41c9e (#23627) 2023-05-15 09:38:32 +02:00
mswin.vim feat(ex_cmds)!: remove :behave 2023-04-13 12:15:30 +02:00
neovim.ico feat(windows): show icon in terminal titlebar, taskbar #20607 2022-10-13 05:48:12 -07:00
nvim.appdata.xml NVIM v0.9.0 2023-04-07 13:26:29 +02:00
nvim.desktop build(nvim.desktop): central Kurdish translation #17065 2022-05-13 11:58:22 -07:00
nvim.png
optwin.vim vim-patch:9.0.0640: cannot scroll by screen line if a line wraps 2023-05-02 13:11:26 +02:00
synmenu.vim vim-patch:3c053a1a5ad2 (#20679) 2022-10-17 08:19:48 +02:00