Commit 6819d4b7 authored by Christian Hergert's avatar Christian Hergert

code: short-circuit save when we think there are no changes

If we have not yet gotten notification of the backing file changed, and
the buffer thinks there are no local modifications, then we can skip the
save operation.

This also helps a situation where we modify a .json flatpak manifest and
invalidate the build pipelines immediately due to the inotify event.

Fixes #757
parent 7766d399
......@@ -1496,6 +1496,18 @@ ide_buffer_save_file_async (IdeBuffer *self,
source_file = alternate;
}
/* Possibly avoid any writing if we can detect a no-change state */
if (file == NULL || g_file_equal (file, ide_buffer_get_file (self)))
{
if (!self->changed_on_volume &&
!gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (self)))
{
ide_notification_set_progress (local_notif, 1.0);
ide_task_return_boolean (task, TRUE);
IDE_GOTO (set_out_param);
}
}
if (self->addins != NULL)
{
IdeBufferFileSave closure = { self, file };
......@@ -1515,6 +1527,7 @@ ide_buffer_save_file_async (IdeBuffer *self,
ide_buffer_save_file_cb,
g_steal_pointer (&task));
set_out_param:
if (notif != NULL)
*notif = g_steal_pointer (&local_notif);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment