Summary: | Incorrect indentation in nested 'if' statements without braces | ||
---|---|---|---|
Product: | [Frameworks and Libraries] frameworks-ktexteditor | Reporter: | Алексей Шилин <rootlexx> |
Component: | general | Assignee: | KWrite Developers <kwrite-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | a.samirh78, ekigwana, karthik.periagaram, waqar.17a |
Priority: | NOR | ||
Version First Reported In: | 5.58.0 | ||
Target Milestone: | --- | ||
Platform: | Arch Linux | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/frameworks/ktexteditor/commit/f1b94f2f8367a07e4ed4b8e33f6061383b3aa44f | Version Fixed In: | 5.91 |
Sentry Crash Report: |
Description
Алексей Шилин
2017-10-07 18:09:53 UTC
With braces it works as expected. int f() { if (1) { if (1) f(); else f(); } else { f(); } } Confirmed using latest released packages. Updating version to indicate. Tested using Arch linux packages (KDE frameworks 5.58.0, Qt 5.12.3, Kwrite 19.04.1). The first "if" must use curly braces because the nested if is intended to be executed as a block, IIUC... (mind you, I only know C++, not C). (In reply to Ahmad Samir from comment #3) > The first "if" must use curly braces because the nested if is intended to be > executed as a block, IIUC... (mind you, I only know C++, not C). That is not correct. The nested conditional construct without explicitly marking off the block scope with {} is valid in both C and C++. A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/259 A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/266 Fixed with 5.91 Git commit f1b94f2f8367a07e4ed4b8e33f6061383b3aa44f by Christoph Cullmann, on behalf of Waqar Ahmed. Committed on 23/01/2022 at 18:31. Pushed by waqar into branch 'master'. Handle single statement condition blocks better See test case for full detail of what is fixed. Essentially it is that if you have something like: ``` if (true) doWork(); ``` and the cursor is on the semicolon, pressing enter should decrease indent level to that of the `if` statement. A +8 -0 autotests/input/indent/cstyle/385472/expected A +3 -0 autotests/input/indent/cstyle/385472/input.js A +7 -0 autotests/input/indent/cstyle/385472/origin M +34 -1 src/script/data/indentation/cstyle.js https://invent.kde.org/frameworks/ktexteditor/commit/f1b94f2f8367a07e4ed4b8e33f6061383b3aa44f |