Editor scrolls down after editing and saving a tex file

Bug #990949 reported by René
210
This bug affects 47 people
Affects Status Importance Assigned to Milestone
gedit-latex-plugin (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

My setup: Ubuntu 12.04 (precise), gedit-latex-plugin 3.4.0-1, gedit 3.4.1-0ubuntu1
To reproduce the bug create a tex file with about 100 lines. Save it, edit it some where around line 50. We end up at the end of the file... really annoying.
I hunted it down to /latex/latex/views.py. It has something to do with the conversion of the outline into a GTK object.

Revision history for this message
Huihuo Zheng (zhenghh04) wrote :

Same problem occurs in my Ubuntu 12.04

Revision history for this message
Huihuo Zheng (zhenghh04) wrote :

I found the solution. It is due to the cursor position issue. Simply use gconf-editor
apps--> gedit-2-->preferences-->cursor_position, check restore_cursor_position.

Changed in gedit-latex-plugin (Ubuntu):
status: New → Fix Committed
Revision history for this message
Huihuo Zheng (zhenghh04) wrote :

sorry, my previous method doesn't work

Changed in gedit-latex-plugin (Ubuntu):
status: Fix Committed → New
Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in gedit-latex-plugin (Ubuntu):
status: New → Confirmed
Revision history for this message
Huihuo Zheng (zhenghh04) wrote :

I finally figure out a method to fix this bug::

One can change /usr/lib/gedit/pluins/latex/latex/editor.py as

    def on_save(self):
        """
        The file has been saved

        Update models
        """
        if self._preferences.get("outline-connect-to-editor"):
            self._preferences.set("outline-connect-to-editor", False)
            self.__parse()
            self._preferences.set("outline-connect-to-editor", True)
        else:
            self.__parse()

This work for me.
The idea is when saving the document, we disconnect the outline and the editor.

Changed in gedit-latex-plugin (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
René (pirateking) wrote :

Confirmed, this fix works for me. Thanks!
You changed the status to "Fix Released" - does that mean the fix will be rolled out in the near future?

Revision history for this message
VS (storvann) wrote :

In Ubuntu, "fix released" means "a fix was uploaded to an official Ubuntu repository", see https://wiki.ubuntu.com/Bugs/Status

I believe the correct status is still "Confirmed" until someone official uploads a new package that includes the proposed fix.

Revision history for this message
C de-Avillez (hggdh2) wrote :

Setting back to Confirmed/Medium. Fix released is restricted to when the fix was put available for download in an Ubuntu package. This issue still exists, and requires (so it seems) a code change.

Although there seems to be a fix for this, it is failing on:
 * it is not a patch
 * it does not identify the version being fixed
 * it has not been acknowledged by upstream.

@Huihuo Zheng: thank you for your work on this bug. Unfortunately, we cannot use it as is, due to the points above. We prefer that upstream acknowledges, and accepts, a patch.

@Any affected: please report this issue (of not already reported) to upstream (https://bugzilla.gnome.org).

Changed in gedit-latex-plugin (Ubuntu):
importance: Undecided → Medium
Revision history for this message
C de-Avillez (hggdh2) wrote :

Somehow I forgot to reset the status to Confirmed. Doing it now.

Changed in gedit-latex-plugin (Ubuntu):
status: Fix Released → Confirmed
Revision history for this message
René (pirateking) wrote :

This bug is already known upstream: https://bugzilla.gnome.org/show_bug.cgi?id=671975

Revision history for this message
robert (robert-kiwanuka) wrote :

The solution in #5 worked for me but it also made my latex plugin unusable. (Ubuntu 12.04, gedit - Version 3.4.1).

Revision history for this message
Jeroen Keiren (jkeiren) wrote :
Revision history for this message
Snahrck (hansenclever) wrote :

I'm really in a hurry to finish an article here, then I applied this patch (http://git.gnome.org/browse/gedit-latex/commit/?id=34542364508a040a283e1d641b17df960da3f646) manually to /usr/lib/gedit/plugins/latex/outline.py but it did not fixed the problem here. This is a very annoying bug. My outline.py after manual patch is like this:

        """
        Expand a path and select the last node
        """
        # disconnect from 'cursor-changed'
        #self._view.disconnect(self._cursor_changed_id)
        selection = self._view.get_selection()
        if not selection:
            return

        # select path
        self._view.expand_to_path(path)
        #self._view.set_cursor(path, None, False)

        # connect to 'cursor-changed' again
        #self._cursor_changed_id = self._view.connect("cursor-changed", self._on_cursor_changed)
        selection.select_path(path)

    #
    # methods to be overridden by the subclass
    #

Revision history for this message
Snahrck (hansenclever) wrote :

Actually it works if you do not select any title in the outline page in the left panel (an advance). However, if you select any title, make a change to the file and save it, it will scroll down to the end of the file.

Revision history for this message
Matthias Jordan (matthiasjordan) wrote :

Funnily, my gedit scrolls to the top of the LaTeX file when I save it. The patch works, though. Thanks a million for it.

Revision history for this message
Vasco Alves (vascofalves) wrote :

That patch is in upstread bugfixing release 3.4.1. Can you please SRU it?

Revision history for this message
Vasco Alves (vascofalves) wrote :

*upstream

Revision history for this message
Audrey Durand (adurand) wrote :

If I uncheck the option "Follow Editor" at the top of the outline page in the left panel, the bug stops happening even though a title is selected in that panel.

Revision history for this message
Michael Tänzer (neoatnhng) wrote :

I have packaged the new version which fixes the bug in my PPA: https://launchpad.net/~neoatnhng/+archive/ppa

Feel free to use this until the new version gets packaged in the official repositories.

Huihuo Zheng (zhenghh04)
security vulnerability: no → yes
visibility: public → private
security vulnerability: yes → no
visibility: private → public
security vulnerability: no → yes
security vulnerability: yes → no
Revision history for this message
Richard Mathie (richard-mathie) wrote :

I have applied the patch, and also tried Michael Tänzer ppa method. Both only fix the issue if you don't click on a section in the latex over view sub plane, or have the follow editor radio button in the off position.

This bug makes the over view pretty much useless, and is pretty annoying when you are typing and gedit decides to auto save, and thus you continue typing over some other part of the document.

I repeat again, both of the 'fixes' mentioned don not fix the bug. they just delay the behaviour until the user interacts with the latex overview sub panel

Revision history for this message
René (pirateking) wrote :

Confirmed, the bug is not fixed yet.

Revision history for this message
Igor Machado (igormcoelho) wrote :

Like Audrey Durand (adurand) said, when I uncheck the option Follow Editor (top left of outline page in the left panel) the bug also disappears for me.

Revision history for this message
Martin Florian (mflorian) wrote :

Same here, unchecking the "Follow Editor" option fixes things. The patch from http://git.gnome.org/browse/gedit-latex/commit/?id=34542364508a040a283e1d641b17df960da3f646, on the other hand, only caused even more random jumps of the cursor.

Revision history for this message
Gabriele N. Tornetta (phoenix1987) wrote :

Please find attached my patch for this bug. I have basically redefined the old _on_cursor_changed into a new method, _cursor_changed_event, and used it inside _on_row_activated. This seems to work nicely, for no stuff is being disconnected and such.

Here's the code (file is outline.py in the main plugin directory):

    def _on_cursor_changed(self, view):
        #Uncomment the line below to get the old behaviour
        #self._cursor_changed_event(view)
        pass

    def _cursor_changed_event(self, view):
        selection = view.get_selection()
        if not selection:
            return

        store, it = selection.get_selected()
        if not it:
            return

        outline_node = store.get_value(it, 2)
        self._on_node_selected(outline_node)

    def _on_row_activated(self, view, path, column):
        it = self._store.get_iter(path)
        node = self._store.get(it, 2)[0]

        self._on_node_activated(node)

        #Comment the line below to get the old behaviour
        self._cursor_changed_event(view)

Revision history for this message
thiago (pereirats) wrote :

The tipe #18 (from Audrey Durand) also worked for me.

Revision history for this message
Ed Harcourt (edharcourt) wrote :

So far #24 has worked for me. Thanks!

Revision history for this message
Thomas Kandler (thomas-kandler) wrote :

I can confirm #24 for me to (CrunchBang Linux waldorf). Thanks. :)

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

Duplicates of this bug

Other bug subscribers

Remote bug watches

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