LSP: The `next_result`/`prev_result` hooks don't jump to the next/prev diagnostic if there are build results

Describe the bug The next_result/prev_result hooks don’t jump to the next/prev diagnostic if there are build results

To Reproduce Steps to reproduce the behaviour:

  1. Initiate a build
  2. Introduce an LSP error in some file
  3. Press f4(the default next_result shortcut)
  4. Observe nothing happens

Expected behaviour The error should be highlighted

Environment (please complete the following information):

  • OS: macOs 0.15.7
  • Sublime Text version: 4107
  • LSP version: 1.4.0
  • Language servers used: ruby(solargraph, sorbet)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 24 (22 by maintainers)

Commits related to this issue

Most upvoted comments

You could still use the same key binding if you add a context, for example

[
    { "keys": ["f4"], "command": "lsp_next_diagnostic", "context": [{"key": "panel_visible", "operand": false}, {"key": "setting.lsp_active"}] },
    { "keys": ["shift+f4"], "command": "lsp_prev_diagnostic", "context": [{"key": "panel_visible", "operand": false}, {"key": "setting.lsp_active"}] },
]

would allow to navigate LSP diagnostics whenever no panel is open.

Note that as a performance optimization, the LSP diagnostics panel updates lazily now, i.e. it only will be updated if it is visible, or when it gets opened. This means that next_result / prev_result won’t work reliably anymore, unless the panel is open. But you can/should add key bindings for lsp_next_diagnostic / lsp_prev_diagnostic instead, which work with closed panel, will only jump to diagnostics in the current tab (the other commands would open other files if the server reports diagnostics for those too), and they wrap around when the last/first diagnostic is reached.