Created attachment 164889 [details] debug log from kate, with lsp logs SUMMARY *** NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols. See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports *** Given the following document of Nix code: let x = 5; in 1 When the formatting button is pressed using the nixd language server, the following becomes the buffer content: in 1 let x = 5; in 1 This is essentially pasting the content of the file a second time, which is a bug. This does not happen in neovim with coc, and I strongly suspect this is a bug in kate's LSP client. This is what the language server responds to the format request with: "{\"id\":4,\"jsonrpc\":\"2.0\",\"result\":[{\"newText\":\"let x = 5;\\nin 1\\n\",\"range\":{\"end\":{\"character\":2147483647,\"line\":2147483647},\"start\":{\"character\":0,\"line\":0}}}]}" This message is intending to overwrite the entire contents of the file with the provided text. However, kate seems to do something different with it. I have attached a full debug log of the LSP interaction. I ran kate with the following: LSPCLIENT_DEBUG=1 QT_FORCE_STDERR_LOGGING=1 QT_LOGGING_RULES='katelspclientplugin=true;default.debug=true' kate --startanon -b bad.nix STEPS TO REPRODUCE 0. Acquire nixd and nixpkgs-fmt from nixpkgs. If you have nix, this can be done with `nix-shell -p nixd nixpkgs-fmt`, then running kate from the resulting shell. 1. Configure kate with nixd like so: { "servers": { "nix": { "command": ["nixd"], "highlightingModeRegex": "^Nix$" } } } 2. Write this into bad.nix: let x = 5; in 1 3. Press the LSP format button 4. Get mangled text OBSERVED RESULT Text is mangled. EXPECTED RESULT Text should be replaced with the new text from the language server. SOFTWARE/OS VERSIONS Operating System: NixOS 24.05 KDE Plasma Version: 5.27.10 KDE Frameworks Version: 5.112.0 Qt Version: 5.15.11 Kernel Version: 6.1.69 (64-bit) Graphics Platform: Wayland Processors: 8 × Intel® Core™ i7-7700HQ CPU @ 2.80GHz Memory: 31.2 GiB of RAM Graphics Processor: Mesa Intel® HD Graphics 630 ADDITIONAL INFORMATION
> result\":[{\"newText\":\"let x = 5;\\nin 1\\n\",\"range\":{\"end\":{\"character\":2147483647,\"line\":2147483647 The server seems to be sending invalid end-line, end-character
https://invent.kde.org/utilities/kate/-/merge_requests/1505