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

            Bug ID: 435936
           Summary: Auto indentation in JS goes berserk inside anonymous
                    function
           Product: kate
           Version: 20.12.3
          Platform: openSUSE RPMs
                OS: Linux
            Status: REPORTED
          Severity: grave
          Priority: NOR
         Component: indentation
          Assignee: kwrite-bugs-n...@kde.org
          Reporter: php4...@gmail.com
  Target Milestone: ---

Created attachment 137713
  --> https://bugs.kde.org/attachment.cgi?id=137713&action=edit
screenshot

SUMMARY


STEPS TO REPRODUCE
1. Create a new .js file and copy this code into it:

document.addEventListener('click', function(event) {
    if (false) console.log("whatever");
});


2. Place the cursor at the end of the middle line, after the ";"
3. Hit the Enter key

OBSERVED RESULT

The new line is insanely indented, 


EXPECTED RESULT

the new line should have the same indentation as the "if" line.


Note that if you try the same outside of the addEventListener(...), it works as
expected.

Also, as far as I can tell, generally speaking, inside the function body auto
indentation is not generally broken. Most of the time it works as expected but
it breaks with the one-line "if" statement without {}s.

By changing the above code to:

document.addEventListener('click', function(event) {
    if (false) {
        console.log("whatever");
    }
});

I don't observe any weirdness in autoindentation.

So, neither the anonymous function inside a function argument list alone, nor
the one-line if statement without {} alone, are enough to cause unexpected
behavior, but somehow the combination of the two things is.




SOFTWARE/OS VERSIONS

Operating System: openSUSE Tumbleweed 20210414
KDE Plasma Version: 5.21.4
KDE Frameworks Version: 5.81.0
Qt Version: 5.15.2
Kernel Version: 5.11.12-1-default
OS Type: 64-bit
Graphics Platform: X11
Processors: 8 × Intel® Core™ i7-1065G7 CPU @ 1.30GHz
Memory: 7.3 GiB of RAM
Graphics Processor: Mesa DRI Intel® Iris® Plus Graphics

ADDITIONAL INFORMATION

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

Reply via email to