1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:37:43 +00:00

SpaceAnalyzer: Do not reset the path to '/' after a refresh

Clicking analyze or deleting a file would always cause the tree view in
the widget to reset back to viewing the root. This was changed to stay
in the directory currently being viewed
This commit is contained in:
Arda Cinar 2022-12-13 12:25:40 +03:00 committed by Sam Atkins
parent c045ae1a96
commit 33ea96912a
3 changed files with 26 additions and 6 deletions

View file

@ -183,7 +183,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto& file_menu = window->add_menu("&File");
file_menu.add_action(GUI::Action::create("&Analyze", [&](auto&) {
if (auto result = analyze(tree, treemapwidget, statusbar); result.is_error()) {
// FIXME: Just modify the tree in memory instead of traversing the entire file system
// FIXME: Dispose of the old tree
auto new_tree = adopt_ref(*new Tree(""));
if (auto result = analyze(new_tree, treemapwidget, statusbar); result.is_error()) {
GUI::MessageBox::show_error(window, DeprecatedString::formatted("{}", result.error()));
}
}));
@ -237,9 +240,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
// TODO: Refreshing data always causes resetting the viewport back to "/".
// It would be great if we found a way to preserve viewport across refreshes.
if (auto result = analyze(tree, treemapwidget, statusbar); result.is_error()) {
// FIXME: Dispose of the old tree
auto new_tree = adopt_ref(*new Tree(""));
if (auto result = analyze(new_tree, treemapwidget, statusbar); result.is_error()) {
GUI::MessageBox::show_error(window, DeprecatedString::formatted("{}", result.error()));
}
});