Don't include `source` code action by default
See original GitHub issueMarksman returns code action of the source
kind (titled Create a Table of Contents
) when editor asks for code actions without explicitly specifying any kind
s.
For example editor make this request:
{
"context": {
"diagnostics": [],
"triggerKind": 2
},
"range": {
"end": {
"character": 0,
"line": 0
},
"start": {
"character": 0,
"line": 0
}
},
"textDocument": {
"uri": "file:///usr/local/workspace/sublime-packages/LSP/README.md"
}
}
and marksman returns:
[
{
"edit": {
"changes": {
"file:///usr/local/workspace/sublime-packages/LSP/README.md": [
{
"newText": "<!--toc:start-->\n- [Installation](#installation)\n - [Stable Version](#stable-version)\n - [Development Version](#development-version)\n- [Getting started](#getting-started)\n- [Getting help](#getting-help)\n<!--toc:end-->\n\n",
"range": {
"end": {
"character": 0,
"line": 0
},
"start": {
"character": 0,
"line": 0
}
}
}
]
}
},
"isPreferred": false,
"kind": "source",
"title": "Create a Table of Contents"
}
]
I don’t have any explicit description of expected behavior for this but based on VSCode primarily (and what we have mirrored in Sublime Text) it seems that the source
code actions should not be returned unless specifically asked for by the editor. Not following this logic results in editor providing source
diagnostics for every location in the file (since editors request diagnostics for the current selection/cursor position) which is non-ideal for those kind of code actions.
(This issue originated from the discussion in https://github.com/sublimelsp/LSP/issues/1846#issuecomment-1255150008)
Issue Analytics
- State:
- Created a year ago
- Comments:13 (5 by maintainers)
Asking some relevant questions in https://github.com/microsoft/language-server-protocol/issues/1554
I found some time to check the behavior in other editors; unfortunately, neither nvim, nor helix, nor emacs/eglot provide code action kind, trigger kind when requesting code actions. Basically, whatever the spec has to say about
only?
in code action request, the actual behavior is idiosyncratic to a particular editor/LSP client.👍