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 787268 - Indenting tabbed blank lines
Indenting tabbed blank lines
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
3.24.x
Other Linux
: Normal enhancement
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2017-09-04 21:20 UTC by Frank
Modified: 2017-09-16 13:57 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Frank 2017-09-04 21:20:45 UTC
I indent with tabs, and I also indent empty lines with tabs for being able to insert something without having to indent that one line every time.

Currently when I select some lines and (un)indent them by pressing “Tab” or “Shift + Tab”, everything is indented, but blank lines stay as they are. Could this case of tabbed blank lines be detected, so that they also get indented by the same amount as lines which do have content?
Comment 1 Christian Hergert 2017-09-05 00:04:00 UTC
Builder (through a wrapper signal so we can apply repeats) just calls gtk_source_view_indent_lines()/gtk_source_view_unindent_lines().

A cursory look over in gtksourceview.c would likely be this code:

https://git.gnome.org/browse/gtksourceview/tree/gtksourceview/gtksourceview.c?h=cba46d776f413a07288ec37edadf07be5fd330e3#n3292

I don't feel strongly either way on whether this is a bug or not, but it seems reasonable to consider it and choose what the intended behavior is.

I don't think choice to ignore whitespace-only lines was made for any reason other than "that's how it was done when implemented".
Comment 2 Sébastien Wilmet 2017-09-05 18:36:10 UTC
I think most of the people don't want trailing spaces, git doesn't like them for example. It's not "clean" to leave trailing spaces…

So it is not a bug, it is a feature.
Comment 3 Frank 2017-09-05 20:23:29 UTC
When you talk about trailing spaces, then this implies, that there must be something in front of them. But I’m talking about complete blank lines. ;)

The fact is, some people code like this – it’s like whether somebody prefers to indent by tabs or by spaces. I disabled the option to delete trailing whitespace, so I expect them not to be deleted (what is done like expected). And when I want to indent some part of code, the whole selection should be indented and not just some part of it. That’s not the way one supposes it to work.
Comment 4 Frank 2017-09-09 01:34:09 UTC
Your argumentation bases purely on opinions, not on facts or actual technical reasons. Letting tabbed lines stay as they are neither helps people who want all “trailing” whitespace to be removed, nor those who use them. So this is both unpredictable and wrong – and thus definitely a bug, no matter how you view it.

Correct me if I’m wrong, but as far as I know also Gedit uses gtksourceview, and coding isn’t the only thing text editors are used for, so the git argument is also invalid. Maybe someone wants to do ASCII art etc. pp.

The option is also called “Indent selection“ and not “Indent just those parts of your selection, the maintainers of gtksourceview like to be indented”.

I just checked other editors and both Vim and Atom indent tabbed lines with the whole blow, and I made absolutely no customizations. A friend of mine verified this for Notepad++, Visual Studio, Visual Studio Code and Netbeans – so come on, sourceview is the absolute only thing doing it wrong!
Comment 5 Frank 2017-09-09 01:35:07 UTC
*block
Comment 6 Christian Hergert 2017-09-09 05:50:25 UTC
(In reply to Frank from comment #4)
> Your argumentation bases purely on opinions, not on facts or actual
> technical reasons.

Statements like this are neither helpful, or likely to persuade the people maintaining the code.
Comment 7 Sébastien Wilmet 2017-09-09 10:23:39 UTC
As far as GtkSourceView is concerned, the behavior won't change. But an application is free to *not* use gtk_source_view_indent_lines() and implement it differently. I don't think it would be useful to provide an option in GtkSourceView.

Moving the bug back to gnome-builder, but IMHO this can be closed as wontfix.
Comment 8 Sébastien Wilmet 2017-09-09 11:03:26 UTC
With git blame we can see that the current behavior (not indenting empty lines) in GtkSourceView was done since the beginning when the function was implemented in 2006:
https://git.gnome.org/browse/gtksourceview/commit/?id=e9f3d760dc6bbb59aae9f8b19716deeeed96e338

And it's the first time that I see someone complaining about this… If we change the behavior, I think way more people would complain. When implementing something, a developer sometimes need to make choices. If we say "yes" to every feature request, we would end up with too many options and an unmaintainable code, see:
http://ometer.com/free-software-ui.html

If you really want to indent empty lines, there is always the possibility to write a plugin.
Comment 9 Frank 2017-09-09 13:30:04 UTC
(In reply to Christian Hergert from comment #6)
> (In reply to Frank from comment #4)
> > Your argumentation bases purely on opinions, not on facts or actual
> > technical reasons.
> 
> Statements like this are neither helpful, or likely to persuade the people
> maintaining the code.

Sorry, I don’t want to offend anyone! But I can’t imagine how the current behaviour helps anyone.

And I don’t talk about empty lines – not indenting empty lines is fine, as people not using tabs want this – so none would be introduced. But already indented lines should be changed according to the block indentation.

Another reason: If I use spaces for indentation, block indentation also applies to empty lines with spaces in it – so why not exactly the same behaviour with tabs?
Comment 10 Sébastien Wilmet 2017-09-09 15:39:56 UTC
Aah, now I understand what you mean: "tabbed blank lines" == non-empty lines containing only spaces or tabs. Should those lines be indented as well? Good question, probably yes.

Moving back to GtkSourceView :-)

When you report a bug, try to describe it as precisely as possible. It's only now that I understand what you mean. You can for example give steps to reproduce the bug.
Comment 11 Frank 2017-09-09 18:46:51 UTC
Sorry again, I thought my description was sufficient. I should add examples in the future…
Comment 12 Sébastien Wilmet 2017-09-15 17:24:17 UTC
Fixed with commit 9c7f94579e7605c2b6188a3e52c65b1e168195d2.
Cherry-picked on gnome-3-24.

The bug was introduced in 2007. It took 10 years for the bug to be reported (and fixed) :-)
Comment 13 Frank 2017-09-16 13:57:14 UTC
Thanks!