[gnome-builder] code: ignore buffer during save-all when externally modified



commit 9743e8580cc73149eab8bff1d299c218d75f8a07
Author: Christian Hergert <chergert redhat com>
Date:   Fri Feb 28 08:36:38 2020 -0800

    code: ignore buffer during save-all when externally modified
    
    If the buffer has been externally modified such from running an external
    command like "rust fmt", then we do not want to save it as part of our
    "save_all" operation run before building.
    
    Fixes #1154

 src/libide/code/ide-buffer-manager.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/src/libide/code/ide-buffer-manager.c b/src/libide/code/ide-buffer-manager.c
index 827ec52d7..ecea05c57 100644
--- a/src/libide/code/ide-buffer-manager.c
+++ b/src/libide/code/ide-buffer-manager.c
@@ -792,6 +792,14 @@ ide_buffer_manager_save_all_foreach_cb (IdeObject *object,
   if (ide_buffer_get_state (buffer) != IDE_BUFFER_STATE_READY)
     return;
 
+  /* If the file is externally modified on disk, don't save it either
+   * so we don't risk overwriting changed files. The user needs to
+   * explicitly overwrite those to avoid loosing work saved outside
+   * of Builder.
+   */
+  if (ide_buffer_get_changed_on_volume (buffer))
+    return;
+
   g_ptr_array_add (state->buffers, g_object_ref (buffer));
 
   state->n_active++;


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