[meld] meldbuffer: Non-existent files should be presented as writable



commit 175f390a427fc7dc7ae88b01eb044a60c0764331
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Oct 1 06:34:57 2017 +1000

    meldbuffer: Non-existent files should be presented as writable
    
    The use case here is that someone does:
        meld a i_dont_exist b
    and in this scenario, the middle pane should be presented as being
    editable, because merging to the middle and then saving it is probably
    what the user wanted.
    
    This scenario also applies to e.g.,
        meld a b c --output d
    where `d` hasn't actually been created yet. You definitely expect the
    pane that will be saved to `d` to be editable by default.

 meld/meldbuffer.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/meld/meldbuffer.py b/meld/meldbuffer.py
index 8c0b763..e26cfe6 100644
--- a/meld/meldbuffer.py
+++ b/meld/meldbuffer.py
@@ -212,7 +212,11 @@ class MeldBufferData(GObject.GObject):
         try:
             info = self.gfiletarget.query_info(
                 Gio.FILE_ATTRIBUTE_ACCESS_CAN_WRITE, 0, None)
-        except (AttributeError, GLib.GError):
+        except GLib.GError as err:
+            if err.code == Gio.IOErrorEnum.NOT_FOUND:
+                return True
+            return False
+        except AttributeError:
             return False
         return info.get_attribute_boolean(Gio.FILE_ATTRIBUTE_ACCESS_CAN_WRITE)
 


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