sublimelsp / LSP

Client implementation of the Language Server Protocol for Sublime Text
https://lsp.sublimetext.io/
MIT License
1.61k stars 182 forks source link

Investigate why didSave notification is not sent if view closed immediately after saving #2461

Open jwortmann opened 1 month ago

jwortmann commented 1 month ago

When a file is saved, a textDocument/didSave notifications should be sent to the server if it opts-in via TextDocumentSyncOptions.

But if the file gets closed immediately after saving, the notification is not sent (at least here on Windows, and apparently also on CI on all OS, but according to https://github.com/sublimelsp/LSP/pull/2438#issuecomment-2054138492 it seems to work in practice on Linux).

Key binding example:

    {
        "keys": ["f1"],
        "command": "chain",
        "args": {
            "commands": [
                ["save", {"async": false}],
                ["close", {}]
            ]
        }
    },

I expect to see textDocument/didSave in the LSP server log panel before textDocument/didClose, but it's missing.

If this gets fixed, this line in the tests could be uncommented: https://github.com/sublimelsp/LSP/blob/4c8da7820cff68901be808ea8bf2fcf14138d249/tests/test_single_document.py#L394