GNOME Bugzilla – Bug 786988
Some indentation problems
Last modified: 2017-09-01 11:30:37 UTC
I encountered pretty annoying indentation issues lately, and I think there was an update on gtksourceview a few days ago (Fedora 26) what is causing this. I defined in .editorconfig: • `indent_style = tab` • `indent_size = 4` and I think Builder defaults to tabs being 4 spaces wide. I just want to use tabs (4 spaces wide) and no space indetation, so every press on tab should fill in a tab and absolutely no spaces. Here you see my problem demonstrated (I entered JUST TABS, no spaces!): https://www.dropbox.com/s/wygefa7gqxw8xse/Builder%20tab%20fault.gif?dl=0 I solved it by commenting out `indent_size = 4` and defining `tab_width = 4`. Christian Hergert commented on this: we just pass those values to gtksourceview... we set GtkSourceView:indent-width and GtkSourceView:tab-width there is also GtkSourceView:insert-spaces-instead-of-tabs, but presumably that is off if you could eventually insert a tab
I've tested with GtkSourceView's test-widget, and there is no problem achieving what you want, just set tab-width to 4. So it's a bug in gnome-builder.
Sébastien, the problem arises when both GtkSourceView:indent-width and GtkSourceView:tab-width are the same value. You can see this in test-widget if you set both to 4. Tabbing from a non-tab-aligned offset results in different behavior. In the case of both set to 4, try deleting "de" from "#include" and hitting tab. You'll get 2 spaces. If you uncheck "Different indent widths", you'll get a tab. Should we not be expecting these to be equivalent behavior? That will require some more complex GSettings mapping funcs if so.
Moving to gtksourceview as incoming patch fixes the issue.
Created attachment 358821 [details] [review] view: handle cases where indent-width and tab-width match Currently, indent-width is set to -1 to set a behavior that it should inherit the value of tab-width. However, if the value actually matches tab-width, a different behavior is applied for the insertion of tabs. This handles that scenario when indenting and lines and inserting tabs.
Thanks for the patch, indeed it was a bug. Pushed: https://git.gnome.org/browse/gtksourceview/commit/?id=14bca910793717f858165d0fec0fe76d5cec19c2 And cherry-picked on gnome-3-24.