Gedit: Remove trailing spaces feature removes last line.

Bug #995747 reported by Jofil Inoc Baring on 2012-05-07
34
This bug affects 6 people
Affects Status Importance Assigned to Milestone
gedit-plugins
New
Medium
gedit (Ubuntu)
Undecided
Unassigned
Precise
Undecided
Unassigned

Bug Description

Ubuntu 12.04 LTS, 64Bit
Gedit 3.4.1

Here's what happend.
1. Launch gedit.
2. Create new file type. I am writing PHP file when I noticed it. So I created a PHP file.
3. Put some codes/strings in there. Be sure your last line is a text.
4. Use Remove trailing spaces feature of gedit.
5. Observe, the last line will be trimmed.

I expect, only trailing spaces will be removed.
I found out that the last line was also remove.
I also use other programming languages and still removes the string.
Attached is the sample string I made.
Open it with gedit 3.4.1 and remove trailing spaces.
The comment should not be removed.

Revision history for this message
Jofil Inoc Baring (baringji) wrote :
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
James Plate (james-plate-deactivatedaccount) wrote :

I duplicated this bug using the reporters file and a local file with the same results.

The code listed for the Remove trailing spaces tool is:

#!/bin/sh

sed 's/[[:blank:]]*$//'

tags: added: usability
Revision history for this message
James Plate (james-plate-deactivatedaccount) wrote :

I should have included :
Ubuntu 12.04 LTS - 64 Bit

gedit:
  Installed: 3.4.1-0ubuntu1
  Candidate: 3.4.1-0ubuntu1
  Version table:
 *** 3.4.1-0ubuntu1 0
        500 http://ubuntu-archives.mirror.nexicom.net/ precise/main amd64 Packages
        100 /var/lib/dpkg/status

---
Ubuntu Bug Squad volunteer triager
http://wiki.ubuntu.com/BugSquad

affects: gedit (Ubuntu) → gedit-plugins (Ubuntu)
Revision history for this message
James Plate (james-plate-deactivatedaccount) wrote :

Output generated when running gedit from terminal and using removetrailing spaces tool:

 :~$ gedit dmesg.txt
Traceback (most recent call last):
  File "/usr/lib/gedit/plugins/externaltools/capture.py", line 197, in on_output
    self.process_read_buffer()
  File "/usr/lib/gedit/plugins/externaltools/capture.py", line 156, in process_read_buffer
    if source == self.pipe.stdout:
NameError: global name 'source' is not defined
Traceback (most recent call last):
  File "/usr/lib/gedit/plugins/externaltools/capture.py", line 197, in on_output
    self.process_read_buffer()
  File "/usr/lib/gedit/plugins/externaltools/capture.py", line 156, in process_read_buffer
    if source == self.pipe.stdout:
NameError: global name 'source' is not defined

List of active plugins:
:~$ gconftool-2 -g /apps/gedit-2/plugins/active-plugins
[joinlines,zeitgeistplugin,gdpfind,filebrowser,externaltools,gdpbzr,bookmarks,spell,docinfo,time,codecomment,colorpicker,gdpformat,modelines]

---
Ubuntu Bug Squad volunteer triager
http://wiki.ubuntu.com/BugSquad

Revision history for this message
James Plate (james-plate-deactivatedaccount) wrote :

Tested on

Ubuntu 10.04.4 LTS Desktop - 32 Bit

gedit:
  Installed: 2.30.3-0ubuntu0.1
  Candidate: 2.30.3-0ubuntu0.1
  Version table:
 *** 2.30.3-0ubuntu0.1 0
        500 http://ca.archive.ubuntu.com/ubuntu/ lucid-updates/main Packages
        100 /var/lib/dpkg/status
     2.30.0git20100413-0ubuntu1 0
        500 http://ca.archive.ubuntu.com/ubuntu/ lucid/main Packages

List of active plugins:
gconftool-2 -g /apps/gedit-2/plugins/active-plugins
[modelines,spell,docinfo,filebrowser,time,externaltools]

No output when started in terminal and running the remove trailing spaces tool that uses identical sed:
#!/bin/sh

sed 's/[[:blank:]]*$//'

So I guess it's not sed's fault.

Revision history for this message
Sabina Jung (sabina-k) wrote :

As the output provided by James Plate (https://bugs.launchpad.net/ubuntu/+source/gedit-plugins/+bug/995747/comments/5) suggests, process_read_buffer() in /usr/lib/gedit/plugins/externaltools/capture.py isn't passed the 'source' argument. That way the processing terminates and the last buffer of the external command's output is lost. Adding the parameter (see patch) solved it for me.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "gedit-externaltools-capture.py-process_read_buffer-source-parameter.patch" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Revision history for this message
Yani Raafezaj (ytraaf) wrote :

Are there any plans for this being fixed? There've been a few gedit updates since then and the problem still persists for me (same version of Ubuntu and gedit).

Changed in gedit-plugins:
importance: Unknown → Medium
status: Unknown → New
Revision history for this message
Rodrigo Dias Cruz (rodrigodc) wrote :

I have just opened a bug against gedit in the Gnome project bugzilla:

https://bugzilla.gnome.org/show_bug.cgi?id=689621

The patch proposed by "Sabina Jung" is attached there as well.

Revision history for this message
Lord Delta (lorddefinitia) wrote :

Hi, this patch works for me too, on:

Kubuntu 12.04.2 LTS

3.2.0-24-generic

Why has no one submitted this yet?

Gedit is rather broken without it.

Revision history for this message
Jeremy Bicha (jbicha) wrote :

This bug doesn't seem to affect the latest version of gedit, 3.8, available in Ubuntu 13.10 Alpha.

affects: gedit-plugins (Ubuntu) → gedit (Ubuntu)
Changed in gedit (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in gedit (Ubuntu Precise):
status: New → Confirmed
Revision history for this message
Ryan A. Pavlik (abiryan) wrote :

Why has this not made it into precise yet?

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

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