After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 781324 - Indentation is incorrect when you press enter after a closing bracket
Indentation is incorrect when you press enter after a closing bracket
Status: RESOLVED OBSOLETE
Product: gnome-builder
Classification: Other
Component: editor
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: GNOME Builder Maintainers
GNOME Builder Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-04-14 17:52 UTC by Timur Kristóf
Modified: 2018-01-11 10:26 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Timur Kristóf 2017-04-14 17:52:19 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.
Comment 1 Patrick Griffis (tingping) 2017-04-14 17:53:16 UTC
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.
Comment 2 Christian Hergert 2017-10-16 08:58:24 UTC
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.
Comment 3 Timur Kristóf 2017-10-16 14:11:46 UTC
Christian, why don't you just use something like clang-format for this sort of stuff?
Comment 4 Christian Hergert 2017-10-16 20:23:05 UTC
(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.
Comment 5 Timur Kristóf 2017-10-17 04:33:28 UTC
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?
Comment 6 Christian Hergert 2017-10-17 04:49:24 UTC
(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).
Comment 7 GNOME Infrastructure Team 2018-01-11 10:26:28 UTC
-- 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.