diff --git a/src/juci.cc b/src/juci.cc index 6cb92e8..f609ce0 100644 --- a/src/juci.cc +++ b/src/juci.cc @@ -45,6 +45,8 @@ void Application::on_activate() { add_window(Window::get()); Window::get().show(); + std::string last_current_file; + if(directories.empty() && files.empty()) { try { boost::property_tree::ptree pt; @@ -57,8 +59,9 @@ void Application::on_activate() { if(!file.empty()) files.emplace_back(file); } + last_current_file=pt.get("current_file"); } - catch(const std::exception &e) {} + catch(const std::exception &) {} } bool first_directory=true; @@ -90,6 +93,9 @@ void Application::on_activate() { for(auto &error: errors) Terminal::get().print(error, true); + + if(!last_current_file.empty()) + Notebook::get().open(last_current_file); } void Application::on_startup() { diff --git a/src/window.cc b/src/window.cc index e1d7389..3a22d37 100644 --- a/src/window.cc +++ b/src/window.cc @@ -812,6 +812,8 @@ bool Window::on_delete_event(GdkEventAny *event) { pt_files.push_back(std::make_pair("", pt_child)); } pt_root.add_child("files", pt_files); + if(notebook.get_current_page()!=-1) + pt_root.put("current_file", notebook.get_current_view()->file_path.string()); boost::property_tree::write_json((Config::get().juci_home_path()/"last_session.json").string(), pt_root); } catch(const std::exception &) {}