From 71dfcbb8789fe9dfa23e5144b432e4a447e5509a Mon Sep 17 00:00:00 2001 From: sumibi-yakitori Date: Mon, 15 Aug 2022 04:25:42 +0900 Subject: [PATCH] Change the initial path in the file dialog to be the currently opened file --- src/app/commands/cmd_open_file.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/app/commands/cmd_open_file.cpp b/src/app/commands/cmd_open_file.cpp index 04473312f..08a4e3a91 100644 --- a/src/app/commands/cmd_open_file.cpp +++ b/src/app/commands/cmd_open_file.cpp @@ -117,6 +117,14 @@ void OpenFileCommand::onExecute(Context* context) if (context->isUIAvailable() && m_filename.empty()) { base::paths exts = get_readable_extensions(); + auto doc = context->activeDocument(); + if (m_folder.empty() && doc) { + auto filename = doc->filename(); + if (!filename.empty()) { + m_folder = base::get_file_path(filename); + } + } + // Add backslash as show_file_selector() expected a filename as // initial path (and the file part is removed from the path). if (!m_folder.empty() && !base::is_path_separator(m_folder[m_folder.size()-1]))