From ae797040cd90793e02c2249ffa941364d1adaf93 Mon Sep 17 00:00:00 2001 From: Jannik Becher Date: Fri, 10 Mar 2023 17:02:30 +0100 Subject: [PATCH] Set default folder when saving a forked notebook (#1767) --- .../live/session_live/persistence_component.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/livebook_web/live/session_live/persistence_component.ex b/lib/livebook_web/live/session_live/persistence_component.ex index a1a835d9a..fa3bd65c5 100644 --- a/lib/livebook_web/live/session_live/persistence_component.ex +++ b/lib/livebook_web/live/session_live/persistence_component.ex @@ -52,7 +52,12 @@ defmodule LivebookWeb.SessionLive.PersistenceComponent do |> assign_new(:attrs, fn -> attrs end) |> assign_new(:new_attrs, fn -> attrs end) |> assign_new(:draft_file, fn -> - file || Livebook.Config.local_file_system_home() + file || + case assigns.session.origin do + # If it's a forked notebook, default to the same folder + {:file, file} -> FileSystem.File.containing_dir(file) + _ -> Livebook.Config.local_file_system_home() + end end) |> assign_new(:saved_file, fn -> file end)