SUMMARY This only happens when LSP Client plugin is enabled, and presumably using rust-analyzer (since that's the one for the Rust language). When editing a source file, if you backspace into a '{'-bracket, then the bracket matching goes haywire and goes into an apparent infinite loop of adding matching '}'-brackets, which can only be stopped by moving the cursor away from the '{'-bracket. This happens even if the "automatically close brackets when opening bracket is typed" or "enclosing characters" options are disabled in Kate settings > Editing. When the bracket explosion happens, it's impossible to undo, because the infinite loop of brackets being added overwhelms the rate at which you can undo, so effectively it's impossible to undo to before the explosion happened. Then you have to move the cursor away and carefully edit the text to achieve your desired edit without triggering the bracket explosion. Because this sort of edit is very common when changing the "use" clauses at the top of the source file, it's effectively impossible to avoid this bug, and it really interferes. This is using the latest release of both Kate AppImage (kate-21.12.3-452-linux-centos_64-gcc.AppImage) and rust-analyzer (downloaded on 2022.03.29) STEPS TO REPRODUCE 1. Create a new cargo binary crate with `cargo new bracket-explosion` (or open an existing one) 2. Run Kate 3. Open file 4. Open bracket-explosion/src/main.rs 5. Put the cursor directly in front of the `p` in `println`. 6. Hit backspace until the `p` backs up into the `{` character. The first line should look like `fn main() {println!("Hello, world!");` OBSERVED RESULT 7. See that an infinite loop of matching '}' brackets are added after the `;`. 8. Move the cursor away (left or right or down) to get the infinite loop to stop. 9. Hit Undo and see that the bracket explosion starts again. EXPECTED RESULT No bracket should be added at all in any of these cases. Simply deleting whitespace between `{` and `p` should not have any other effect. SOFTWARE/OS VERSIONS Windows: macOS: Linux/KDE Plasma: Ubuntu 18.04 (available in About System) KDE Plasma Version: 5.12.9.1-0ubuntu0.1 (I'm not sure this is relevant because I'm using the Kate AppImage) KDE Frameworks Version: Not sure Qt Version: ADDITIONAL INFORMATION
Hi, I haven't checked whether the issue is in Kate or rust-analyzer, but for now just disable "Configure Kate... -> LSP -> Format On Typing" and it will fix the issue.
Thanks, that workaround does indeed work!
Propposed a fix for the infinite case in Kate: https://invent.kde.org/utilities/kate/-/merge_requests/693 However, I suggest you to report this to rust-analyzer as well as the formatting it is trying to do makes little sense to me (the brackets are already balanced, it shouldn't try to add new brackets).
Git commit 4845de3df81ec6ad0a15be5cad163ab9b9d4b53a by Waqar Ahmed. Committed on 30/03/2022 at 14:44. Pushed by waqar into branch 'master'. Fix possible infinite formatting calls M +5 -0 addons/lspclient/lspclientpluginview.cpp https://invent.kde.org/utilities/kate/commit/4845de3df81ec6ad0a15be5cad163ab9b9d4b53a
Git commit e834835afb7b3ad58c19abc0bb0c0bf0f18d9633 by Waqar Ahmed. Committed on 31/03/2022 at 06:33. Pushed by waqar into branch 'release/22.04'. Fix possible infinite formatting calls (cherry picked from commit 4845de3df81ec6ad0a15be5cad163ab9b9d4b53a) M +5 -0 addons/lspclient/lspclientpluginview.cpp https://invent.kde.org/utilities/kate/commit/e834835afb7b3ad58c19abc0bb0c0bf0f18d9633