Skip to content

getAutofixMode: will_save_wait_until depends on workspace/applyEdit being supported #2194

Description

@dchinmay2

Zig Version

0.13.0

ZLS Version

0.13.0

Client / Code Editor / Extensions

emacs with lspce (https://github.com/zbelial/lspce)

Steps to Reproduce and Observed Behavior

In getAutofixMode, the will_save_wait_until mode depends on workspace/applyEdit being supported by the client. This is a problem because lspce doesn't support any server->client requests at all, which means lspce doesn't get autofixes even though it could after this PR is merged zbelial/lspce#46

Expected Behavior

server.client_capabilities.supports_will_save_wait_until is checked for separately. I can confirm that autofixes work after this change + the linked lspce PR:

diff --git a/src/Server.zig b/src/Server.zig
index c7a30ee..1a2ccc2 100644
--- a/src/Server.zig
+++ b/src/Server.zig
@@ -330,8 +330,10 @@ fn getAutofixMode(server: *Server) enum {
     if (!server.config.enable_autofix) return .none;
     // TODO https://github.com/zigtools/zls/issues/1093
     // if (server.client_capabilities.supports_code_action_fixall) return .fixall;
+    if (server.client_capabilities.supports_will_save_wait_until) {
+        return .will_save_wait_until;
+    }
     if (server.client_capabilities.supports_apply_edits) {
-        if (server.client_capabilities.supports_will_save_wait_until) return .will_save_wait_until;
         return .on_save;
     }
     return .none;

Also if you decide to implement this, can you please backport it to 0.13?

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions