Bug 408820 - indent re-aligns (incorrectly) indented "if blocks" in C code
Summary: indent re-aligns (incorrectly) indented "if blocks" in C code
Status: RESOLVED NOT A BUG
Alias: None
Product: kate
Classification: Applications
Component: application (show other bugs)
Version: 19.04.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-17 10:40 UTC by cat22
Modified: 2019-06-21 14:39 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
editing options settings (87.54 KB, image/png)
2019-06-18 05:49 UTC, cat22
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cat22 2019-06-17 10:40:00 UTC
SUMMARY
If I highlight the entire block (select by lines, e.g set cursor in column 1 (press home key twice) and press shift down arrow until all the lines are selected) and press Ctrl+i the block is moved to the right but the already indented code becomes column aligned.

e.g:
        if(open_database(&mysql)) {
           log_error("ERROR!!! Failed to open database\n");
           debug_print("LEAVE\n");
           return -1;
        }
becomes
        if(open_database(&mysql)) {
        log_error("ERROR!!! Failed to open database\n");
        debug_print("LEAVE\n");
        return -1;
        }

I played with the settings for indentation but couldn't fix it

STEPS TO REPRODUCE
1. 
2. 
3. 

OBSERVED RESULT
            if(open_database(&mysql)) {
            log_error("ERROR!!! Failed to open database\n");
            debug_print("LEAVE\n");
            return -1;
            }


EXPECTED RESULT
            if(open_database(&mysql)) {
               log_error("ERROR!!! Failed to open database\n");
               debug_print("LEAVE\n");
               return -1;
            }


SOFTWARE/OS VERSIONS


Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: No longer reported in 'About KDE' in Kate! Why is that?!?!
Determined from other sourcesits KDE 5.58.0 Plasma 5.16.05.12.3

KDE Frameworks Version: 
Qt Version:  Unknown, how does one get this info? I think its 5.12.3

ADDITIONAL INFORMATION
Opensuse Tumbleweed x86_64
Comment 1 Ahmad Samir 2019-06-17 16:43:51 UTC
The first block of code you posted, the indentation of the code inside the if loop is using only 3 spaces, if you set the "indentation width" to 4 spaces, then that's what's confusing ktexteditor here, IIUC.
Comment 2 cat22 2019-06-18 05:49:01 UTC
Created attachment 120964 [details]
editing options settings
Comment 3 cat22 2019-06-18 05:50:13 UTC
Comment on attachment 120964 [details]
editing options settings

The examples i posted might have had there spacing off. I checked in kates settings and indentation is set to 4 spaces:
See attached screen shot
Comment 4 Ahmad Samir 2019-06-18 10:05:44 UTC
If you correct the spacing/indenting of the code inside the if loop, does kate work as you expect?
Comment 5 cat22 2019-06-19 17:41:23 UTC
Yes, it appears to work if i do that.
Comment 6 Ahmad Samir 2019-06-20 12:45:27 UTC
If you agree this isn't a bug please close the report; thanks.