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 786988 - Some indentation problems
Some indentation problems
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
3.24.x
Other Linux
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2017-08-29 20:39 UTC by Frank
Modified: 2017-09-01 11:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
view: handle cases where indent-width and tab-width match (1.42 KB, patch)
2017-08-31 08:39 UTC, Christian Hergert
none Details | Review

Description Frank 2017-08-29 20:39:47 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
Comment 1 Sébastien Wilmet 2017-08-30 10:19:04 UTC
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.
Comment 2 Christian Hergert 2017-08-30 19:42:17 UTC
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.
Comment 3 Christian Hergert 2017-08-31 08:38:40 UTC
Moving to gtksourceview as incoming patch fixes the issue.
Comment 4 Christian Hergert 2017-08-31 08:39:14 UTC
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.
Comment 5 Sébastien Wilmet 2017-09-01 11:30:37 UTC
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.