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 721469 - Automatic indentation should not add trailing whitespace
Automatic indentation should not add trailing whitespace
Status: RESOLVED WONTFIX
Product: gedit
Classification: Applications
Component: general
3.10.x
Other Linux
: Normal normal
: ---
Assigned To: Gedit maintainers
Gedit maintainers
Depends on:
Blocks:
 
 
Reported: 2014-01-04 18:03 UTC by Michael Catanzaro
Modified: 2016-11-26 22:46 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Michael Catanzaro 2014-01-04 18:03:19 UTC
Simple example: try to edit this code with Enable Automatic Indentation set:

#include <stdio.h>
int main (void)
{
  printf ("hello world\n");
}

Move the cursor to the end of the line with the printf and hit Enter.  The next line starts indented two spaces, as expected: great if you want to write some code on that line. But instead of placing code on that line, decide that you want to leave a blank line between that and the next statement, so hit Enter again and add another line of code.  Now you have, with underscores representing spaces:

#include <stdio.h>
int main (void)
{
__printf ("hello world\n");
__
__printf ("hm\n");
}

The line in the middle is widely considered to be a whitespace error, which many projects (e.g. GTK+) don't allow in patches. Other editors with automatic indentation, such as Anjuta, will immediately delete the whitespace they added if you don't write anything on that line. gedit should do the same (or else grow an option for removing trailing whitespace from modified lines when saving, as suggested in Bug #305816).

FWIW, I disable automatic indentation in gedit for this reason.
Comment 1 jessevdk@gmail.com 2014-01-04 18:53:21 UTC
At some point we changed the behavior to the one you are proposing, but we got a lot of negative feedback on it (see #617907, #653409, #617681). In the end, we decided to revert to the old behavior.

I'm personally in the camp that it's of great annoyance to keep these spaces, but I suppose it all depends on what you use gedit for. Apparently not everyone agrees to the same thing. I've created a plugin a while ago that strips the spaces, you can find it here: https://github.com/jessevdk/gedit-stripper-plugin

In the end, I think it would be great to make stripping these spaces a user preference in gtksourceview/gedit since some people clearly prefer one over the other, but there doesn't seem to be a majority either way.
Comment 2 jessevdk@gmail.com 2014-01-04 18:54:02 UTC
For reference, bug #617907, bug #653409 and bug #617681
Comment 3 Michael Catanzaro 2014-01-04 21:27:58 UTC
(In reply to comment #1)
> In the end, I think it would be great to make stripping these spaces a user
> preference in gtksourceview/gedit since some people clearly prefer one over the
> other, but there doesn't seem to be a majority either way.

Oh, I was not aware that there were users that desire this trailing whitespace.

My $0.02: a preference that controls this behavior of automatic indentation might be confusing. Perhaps that plugin (which does exactly what I want, thanks!) could live in gedit-plugins, or better, be installed by default?  (Or better, be enabled by default? It doesn't make sense to me that automatic indentation should be incompatible with many open source projects....)
Comment 4 Kevin Hagner 2016-11-26 22:46:59 UTC
Because the bug is actually a feature, nothing more will be done.