From d467fca818c9780462669d3c8f27832f6ecc0834 Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 20 Feb 2017 21:38:49 +0100 Subject: [PATCH] Cleanup of terminal link click --- src/terminal.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/terminal.cc b/src/terminal.cc index 62365a1..404d8ee 100644 --- a/src/terminal.cc +++ b/src/terminal.cc @@ -355,19 +355,18 @@ bool Terminal::on_button_press_event(GdkEventButton* button_event) { std::string path_str=get_buffer()->get_text(start_iter, end_iter); std::smatch sm; if(std::regex_match(path_str, sm, link_regex)) { - auto path_str=sm[1].str()+sm[2].str(); - auto path=boost::filesystem::path(path_str); + auto path=boost::filesystem::path(sm[1].str()+sm[2].str()); if(path.is_relative()) { if(Project::current) { - path=Project::current->build->get_default_path()/path_str; - if(!boost::filesystem::is_regular_file(path)) - path=Project::current->build->get_debug_path()/path_str; + auto absolute_path=Project::current->build->get_default_path()/path; + if(boost::filesystem::exists(absolute_path)) + path=absolute_path; + else + path=Project::current->build->get_debug_path()/path; } else return Gtk::TextView::on_button_press_event(button_event); } - else - path=path_str; if(boost::filesystem::is_regular_file(path)) { Notebook::get().open(path); if(auto view=Notebook::get().get_current_view()) {