FileManager: Simplify breadcrumb bar hook callback
Now that we store each partial path with the segments, we can just open up the path of the segment you clicked on.
This commit is contained in:
parent
7e78e4b232
commit
dd9a77099f
Notes:
sideshowbarker
2024-07-19 00:49:02 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/dd9a77099fa
1 changed files with 2 additions and 15 deletions
|
@ -655,21 +655,8 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
|||
|
||||
breadcrumb_bar.set_selected_segment(breadcrumb_bar.segment_count() - 1);
|
||||
|
||||
breadcrumb_bar.on_segment_click = [&directory_view, lexical_path](size_t segment_index) {
|
||||
if (segment_index == 0) {
|
||||
directory_view.open("/");
|
||||
return;
|
||||
}
|
||||
size_t part_index = segment_index - 1;
|
||||
ASSERT(part_index < lexical_path.parts().size());
|
||||
|
||||
StringBuilder builder;
|
||||
for (size_t i = 0; i <= part_index; ++i) {
|
||||
builder.append('/');
|
||||
builder.append(lexical_path.parts()[i]);
|
||||
}
|
||||
|
||||
directory_view.open(builder.string_view());
|
||||
breadcrumb_bar.on_segment_click = [&](size_t segment_index) {
|
||||
directory_view.open(breadcrumb_bar.segment_data(segment_index));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue