https://bugs.kde.org/show_bug.cgi?id=442340
Bug ID: 442340
Summary: Nonsensical JS auto-indent after one-line if statement
Product: kate
Version: 21.04.3
Platform: openSUSE RPMs
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: indentation
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
SUMMARY
After a one-line self-contained if statement such as:
if (whatever()) doSomething();
under certain scenarios, kate wrongly auto-indents with several spaces (namely
6 spaces which is a nonsensical quantity as it is not a multiple of 4). This
should produce no indent at all since it's a self-contained one-line statement.
STEPS TO REPRODUCE
1. Create a .js file
2. Paste this code (without the //////s):
////////////////
var a = [];
a.forEach(function(item) {
if (item.x===undefined) return;
});
////////////////
3. Position the cursor at the end of the "if...return;" line
4. Hit Enter
OBSERVED RESULT
The next line is indented +6 spaces with respect to the previous one
EXPECTED RESULT
There should be no additional indentation. The new line should be indented with
as many spaces as precede the "if".
Note that this simpler code does not reproduce:
//////
if (3<4) return;
//////
nor this:
/////////
function myFunction() {
if (3<4) return;
}
/////////
The anonymous function passed as argument to a function seems to be somehow
required to reproduce.
On the other hand, the following also produces nonsensical auto-indentation:
////////////////
(function() {
if (true) return;
})();
///////////////
In this case, when inserting a newline after "return;", the new line gets
un-indented with respect to the previous one, with only one absolute space.
SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20210807
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.84.0
Qt Version: 5.15.2
Kernel Version: 5.13.8-1-default (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.