GNOME Bugzilla – Bug 781324
Indentation is incorrect when you press enter after a closing bracket
Last modified: 2018-01-11 10:26:28 UTC
Take the following simple C program: int main(int argc, char **argv) { if (argc == 1) { } return 0; } With the cursor go to line 4 after the closing bracket, then press enter. The indentation on the new line will be incorrect.
As mentioned in IRC this seems to be caused by the placement of the first {. If you put it on its own line it understands the correct indentation level.
We should probably up the priority of copying the previous line. If I didn't hate our current C indenter implementation so much, this would have been fixed already.
Christian, why don't you just use something like clang-format for this sort of stuff?
(In reply to Timur Kristóf from comment #3) > why don't you just use something like clang-format for this sort > of stuff? clang-format is for syntactically correct source files, and you almost never have a syntactically correct source file when indentation comes into play. Furthermore, it can't be used to indent an empty lines which is where our insertion cursor will land. Interactive-indentation and code-reformatting are really two very different problem domains. Also, clang-format doesn't support GNU-style C, which is our primary indentation mode until something "better" is written.
Which part of the GNU style isn't supported by clang-format? It's pretty well configurable, so I would think it's possible to configure it to use GNU-style C. Or isn't it?
(In reply to Timur Kristóf from comment #5) > Which part of the GNU style isn't supported by clang-format? It's pretty > well configurable, so I would think it's possible to configure it to use > GNU-style C. Or isn't it? It's sort of irrelevant. We already support clang-format through the beautifiers engine for people that want to do whole-file formatting. But in particular, it's not smart enough to do GNOME style parameter alignments correctly. (Neither is uncrustify).
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnome-builder/issues/220.