Skip to content
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

codeAction does not work in Helix editor #28

Closed
tsugumi-sys opened this issue Dec 24, 2022 · 5 comments · Fixed by #33
Closed

codeAction does not work in Helix editor #28

tsugumi-sys opened this issue Dec 24, 2022 · 5 comments · Fixed by #33

Comments

@tsugumi-sys
Copy link

codeAction does not work in Helix editor.

image

I can select actions but do nothing. I'm searching now but do you have any idea?

I check the output (actions) of here,, the actions returned correctlly.

INFO:exampleLogger:[CodeAction(title='Ruff: Organize Imports', kind=<CodeActionKind.SourceOrganizeImports: 'source.organizeImports'>, diagnostics=[], is_preferred=None, disabled=None, edit=None, command=None, data='file:///home/akira/akira/oss/ruff-lsp/ruff_lsp/complete.py'), CodeAction(title='Ruff: Fix All', kind='source.fixAll.ruff', diagnostics=[], is_preferred=None, disabled=None, edit=None, command=None, data='file:///home/akira/akira/oss/ruff-lsp/ruff_lsp/complete.py')]
@tsugumi-sys
Copy link
Author

tsugumi-sys commented Dec 24, 2022

CodeAction(..., edit=None, ...) This is why code edit doesn't happen.

Here is codeActionParams of code_action(params: ...) when I call Ruff: Organize Imports.

INFO:exampleLogger:params: CodeActionParams(text_document=TextDocumentIdentifier(uri='file:///home/akira/akira/oss/ruff-lsp/ruff_lsp/complete.py'), range=3:0-3:1, context=CodeActionContext(diagnostics=[Diagnostic(range=0:0-6:0, message='Import block is un-sorted or un-formatted', severity=<DiagnosticSeverity.Warning: 2>, code='I001', code_description=None, source='Ruff', tags=None, related_information=None, data=None)], only=None, trigger_kind=None), work_done_token=None, partial_result_token=None)

If params.context.only=None, _create_workspace_edits in https://github.com/charliermarsh/ruff-lsp/blob/c4ecadde49f19c9f16fcf3d3910b1f6a71878fc2/ruff_lsp/server.py#L283 is not called. However, it might not be not problem because resolve_code_action is called instead.

@charliermarsh
Copy link
Member

I can try it out tomorrow (hopefully). Thanks for reporting.

(edit=None might be ok, because of the “code action resolve” handler, which generates the actual edit after the user selects it (thereby editing lazily).)

@tsugumi-sys
Copy link
Author

codeAction/resolve does not supported yet...
helix-editor/helix#5118

@charliermarsh
Copy link
Member

Ah dang. Perhaps there’s a way to detect that it’s unsupported and return the edits directly? Or can just wait for Helix to implement that part of the spec.

@tsugumi-sys
Copy link
Author

tsugumi-sys commented Dec 24, 2022

I look into it: Perhaps there’s a way to detect that it’s unsupported and return the edits directly?
And I'll try to fix that issue (but it will take some time because I'm new to Rust and LSP)

Maybe we can use this.

We can access via
InitializeParams -> capabilities (ClientCapabilities) -> text_document (TextDocumentClientCapabilities) -> code_action (CodeActionClientCapabilities) -> resolve_support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants