Skip to content

Commit

Permalink
pathfinder: use parent directory of marked file if directory doesn't …
Browse files Browse the repository at this point in the history
…exist when jumping
  • Loading branch information
XPhyro committed Aug 21, 2024
1 parent a0e5af1 commit afa99ff
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/cpp/project/pathfinder/src/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,18 @@ PAF_CMD_NORETURN void paf::jump::execute(const lyra::group& group)
xph::die_if(!m_keycode->size(), "<keycode> cannot be empty");
}

auto db = db::get_db(db_type::directory);
auto dir = db.try_get_mark(*m_keycode);
auto dir_db = db::get_db(db_type::directory);
auto dir = dir_db.try_get_mark(*m_keycode);

if (!dir) {
auto file_db = db::get_db(db_type::file);
auto file = file_db.try_get_mark(*m_keycode);

xph::die_if(!file, "keycode [", *m_keycode, "] not found in database");

dir = fs::path(*file).parent_path();
}

xph::die_if(!dir, "keycode [", *m_keycode, "] not found in database");
std::cout << *dir << '\n';

PAF_CMD_EXIT();
Expand Down

0 comments on commit afa99ff

Please sign in to comment.