https://bugs.kde.org/show_bug.cgi?id=452047

            Bug ID: 452047
           Summary: When editing Rust code, backspacing into a '{'-bracket
                    causes a runaway matching '}'-bracket explosion
           Product: kate
           Version: 21.12.3
          Platform: Appimage
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: application
          Assignee: kwrite-bugs-n...@kde.org
          Reporter: victor.d...@gmail.com
  Target Milestone: ---

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

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to