gedit doesn't show last newline

Bug #1621732 reported by Ray Satiro
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
gedit (Ubuntu)
Invalid
Low
Unassigned

Bug Description

echo 'foo' | tee -a testfile

od -t x1 testfile
0000000 66 6f 6f 0a
0000004

gedit testfile

It shows foo as if it doesn't end in a linefeed. In other words I'd expect the last place I could set the cursor as below the line with foo but instead the last place is right after the last o.

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: gedit 3.18.3-0ubuntu4
ProcVersionSignature: Ubuntu 4.4.0-36.55-generic 4.4.16
Uname: Linux 4.4.0-36-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.1
Architecture: amd64
CurrentDesktop: Unity
Date: Fri Sep 9 00:39:20 2016
InstallationDate: Installed on 2013-10-23 (1051 days ago)
InstallationMedia: Ubuntu 13.10 "Saucy Salamander" - Release amd64 (20131016.1)
SourcePackage: gedit
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Ray Satiro (raysatiro) wrote :
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. The issue you are reporting is an upstream one and it would be nice if somebody having it could send the bug to the developers of the software by following the instructions at https://wiki.ubuntu.com/Bugs/Upstream/GNOME. If you have done so, please tell us the number of the upstream bug (or the link), so we can add a bugwatch that will inform us about its status. Thanks in advance.

Changed in gedit (Ubuntu):
importance: Undecided → Low
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gedit (Ubuntu):
status: New → Confirmed
Revision history for this message
Skeukry (skeukry) wrote :

This command fixes this issue (somewhat):
gsettings set org.gnome.gedit.preferences.editor ensure-trailing-newline false

By disabling the automatic addition of a last newline, gedit will show the actual last newline. I would argue that it's rather an issue of 'ensure-trailing-newline' being unintuitive.
see: https://bugzilla.gnome.org/show_bug.cgi?id=625955

Revision history for this message
Edgar Bonet (linu7) wrote :

It's not a bug, it's a feature.

In the Unix world, a line of text ends with the <newline> character, by
definition. A file consisting solely of the four-byte sequence "foo\n"
contains only one line. And this is what gedit *correctly* shows.

See "Why should text files end with a newline?":
https://stackoverflow.com/questions/729692

The proposed fix makes it very easy to create invalid text files, which
is fine if that is really what the use wants, but it is a good thing
that it is not the default behavior.

The bug status should be changed to "invalid".

Changed in gedit (Ubuntu):
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.