Преглед на файлове

GMLPlayground: Set file path when reading file

We weren't setting the path on the 'Open' action, which meant that a
startup file name was always visible in the title bar (unless we save a
file to a different path, or pick a file from the 'recent files' list).

By setting it to update the stored file path in the load_file()
function, it'll be guaranteed the file name will always be set.

This also will add the startup opened file to the recently opened files
list.
Karol Kosek преди 2 години
родител
ревизия
3c13faff57
променени са 1 файла, в които са добавени 2 реда и са изтрити 4 реда
  1. 2 4
      Userland/DevTools/GMLPlayground/main.cpp

+ 2 - 4
Userland/DevTools/GMLPlayground/main.cpp

@@ -136,6 +136,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
 
         editor->set_text(buffer_or_error.release_value());
         editor->set_focus(true);
+        file_path = file.filename().to_deprecated_string();
         update_title();
 
         GUI::Application::the()->set_most_recently_open_file(file.filename());
@@ -209,7 +210,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
         auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, action.text());
         if (response.is_error())
             return;
-        file_path = response.value().filename().to_deprecated_string();
         load_file(response.release_value());
     }));
 
@@ -337,9 +337,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
         update_title();
     } else {
         auto file = TRY(FileSystemAccessClient::Client::the().request_file_read_only_approved(window, path));
-        file_path = path;
-        editor->set_text(TRY(file.release_stream()->read_until_eof()));
-        update_title();
+        load_file(move(file));
     }
 
     return app->exec();