Skip to content

Commit 299cebb

Browse files
trflynn89awesomekling
authored andcommitted
FileManager: Do not activate "Show Dotfiles" action on every startup
Commit 75d1840 detects if the initial path provided to the FileManager contains a dotfile, and if so, forces the FileManager to show dotfiles. However, it does this by activating the "Show Dotfiles" action. This has the side effect of always setting and persisting the configuration, overriding whatever the user's preference was. Instead, only transiently update the view to show dotfiles if the path contains a dotfile.
1 parent d26203f commit 299cebb

File tree

1 file changed

+8
-7
lines changed
  • Userland/Applications/FileManager

1 file changed

+8
-7
lines changed

Userland/Applications/FileManager/main.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -986,20 +986,21 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
986986
TRY(edit_menu->try_add_separator());
987987
TRY(edit_menu->try_add_action(select_all_action));
988988

989+
auto show_dotfiles_in_view = [&](bool show_dotfiles) {
990+
directory_view->set_should_show_dotfiles(show_dotfiles);
991+
directories_model->set_should_show_dotfiles(show_dotfiles);
992+
};
993+
989994
auto show_dotfiles_action = GUI::Action::create_checkable("&Show Dotfiles", { Mod_Ctrl, Key_H }, [&](auto& action) {
990-
directory_view->set_should_show_dotfiles(action.is_checked());
991-
directories_model->set_should_show_dotfiles(action.is_checked());
995+
show_dotfiles_in_view(action.is_checked());
992996
refresh_tree_view();
993997
Config::write_bool("FileManager"sv, "DirectoryView"sv, "ShowDotFiles"sv, action.is_checked());
994998
});
995999

9961000
auto show_dotfiles = Config::read_bool("FileManager"sv, "DirectoryView"sv, "ShowDotFiles"sv, false);
997-
directory_view->set_should_show_dotfiles(show_dotfiles);
1001+
show_dotfiles |= initial_location.contains("/."sv);
9981002
show_dotfiles_action->set_checked(show_dotfiles);
999-
1000-
auto const initial_location_contains_dotfile = initial_location.contains("/."sv);
1001-
show_dotfiles_action->set_checked(initial_location_contains_dotfile);
1002-
show_dotfiles_action->on_activation(show_dotfiles_action);
1003+
show_dotfiles_in_view(show_dotfiles);
10031004

10041005
auto view_menu = TRY(window->try_add_menu("&View"));
10051006
auto layout_menu = TRY(view_menu->try_add_submenu("&Layout"));

0 commit comments

Comments
 (0)