Skip to content

Commit

Permalink
fix: prevent segfault when navigating up a directory
Browse files Browse the repository at this point in the history
Fixes a segfault when leaving a directory with 'h' or the left arrow key after entering with Enter.

Fixes boysetsfrog#97.
  • Loading branch information
sidtronics committed Oct 2, 2024
1 parent 95ad78d commit 1221285
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/window/directorywindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,19 @@ void DirectoryWindow::Confirm()
{
if (directory_.Get(CurrentLine())->type_ == Mpc::PathType)
{
bool is_parent_dir = directory_.Get(CurrentLine())->name_ == "..";
directory_.ChangeDirectory(*directory_.Get(CurrentLine()));
ScrollTo(0);

if (is_parent_dir)
{
ScrollTo(selection_.top());
selection_.pop();
}
else
{
selection_.push(CurrentLine());
ScrollTo(0);
}
}
else
{
Expand Down

0 comments on commit 1221285

Please sign in to comment.