[meld] filediff: Ignore cursor changes for non-focused panes (#646)



commit 7df17adb676959587c137774d9d55952794df104
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Aug 13 13:24:21 2022 +1000

    filediff: Ignore cursor changes for non-focused panes (#646)
    
    Certain actions (such as pushing a chunk to a pane) manually trigger our
    cursor change logic, which means that we can get cursor change
    notifications for panes that aren't focused. This was causing confusion
    because actions such as next/previous chunk would check the cursor
    line number and get the line number from a non-focused pane.
    
    The fix here is fairly simple; we just don't run our cursor-changed
    logic if the cursor change happens in a pane that isn't focused.

 meld/filediff.py | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index f12d3601..5dde307d 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -615,6 +615,12 @@ class FileDiff(Gtk.VBox, MeldDoc):
         return (line, offset)
 
     def on_cursor_position_changed(self, buf, pspec, force=False):
+
+        # Avoid storing cursor changes for non-focused panes. These
+        # happen when we e.g., copy a chunk between panes.
+        if not self.focus_pane or self.focus_pane.get_buffer() != buf:
+            return
+
         pane = self.textbuffer.index(buf)
         pos = buf.props.cursor_position
         if pane == self.cursor.pane and pos == self.cursor.pos and not force:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]