summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorangel <angel@ttm.sh>2020-04-19 15:11:43 +0200
committerAndreas Kling <kling@serenityos.org>2020-04-19 15:23:16 +0200
commit0ec37c0d64d9f5a8093521041700dd76fbcefb57 (patch)
treedbe2ea72da6296988857542e0fb6016f7e8b8bc9
parent440f01794655b8ab6bb244c8fe70b7523e38dc35 (diff)
downloadserenity-0ec37c0d64d9f5a8093521041700dd76fbcefb57.zip
FileManager: Ignore empty selections on tree view
If the selection is empty, the model index will be invalid and the file system model will return the root directory path by default. This causes the file manager to jump to the root directory when the currently selected item on the tree view is deselected.
-rw-r--r--Applications/FileManager/main.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp
index 90b0d10caa..4350056dd3 100644
--- a/Applications/FileManager/main.cpp
+++ b/Applications/FileManager/main.cpp
@@ -702,6 +702,8 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
};
tree_view.on_selection_change = [&] {
+ if (tree_view.selection().is_empty())
+ return;
auto path = directories_model->full_path(tree_view.selection().first());
if (directory_view.path() == path)
return;