[gnome-builder] buffer: set buffer modified when backing file is lost



commit 2f05d07c5f0379dda42a7b4b6199121593f4c27c
Author: Christian Hergert <chergert redhat com>
Date:   Sun Oct 7 23:48:19 2018 -0700

    buffer: set buffer modified when backing file is lost
    
    If we detect that the backing file has been lost (failed to locate
    GFileInfo) then ensure that we mark the buffer modified so that the user
    can save it again.
    
    I might rather see this done in a way that tells the user the file was
    deleted, similar to the "reload" bar we have. But instead show two options
    to close/save.
    
    This at least allows them to save the file though.
    
    Fixes #659

 src/libide/buffers/ide-buffer.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/src/libide/buffers/ide-buffer.c b/src/libide/buffers/ide-buffer.c
index 65809cea5..692c128d9 100644
--- a/src/libide/buffers/ide-buffer.c
+++ b/src/libide/buffers/ide-buffer.c
@@ -2668,6 +2668,20 @@ ide_buffer__check_for_volume_cb (GObject      *object,
             _ide_buffer_set_changed_on_volume (self, TRUE);
         }
     }
+  else
+    {
+      GtkTextIter iter;
+
+      /* If we get here, the file likely does not exist on disk. We might have
+       * a situation where the file was moved out from under the user. If so,
+       * then we should mark the buffer as modified so that the user can save
+       * it going forward.
+       */
+
+      gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (self), &iter);
+      if (gtk_text_iter_get_offset (&iter) != 0)
+        gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (self), TRUE);
+    }
 }
 
 /**


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