Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.

Commit 9438568

Browse files
committed
feature: auto reload plugins on save and expand api
1 parent c688fb5 commit 9438568

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/window.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,21 @@ void Window::set_menu_actions() {
391391
Notebook::get().get_view(c)->configure();
392392
Notebook::get().configure(c);
393393
}
394+
if(view->file_path>Config::get().python.plugin_directory){
395+
auto stem=view->file_path.stem().string();
396+
auto module=PythonInterpreter::get().get_loaded_module(stem);
397+
if(module){
398+
auto module_new=pybind11::module(PyImport_ReloadModule(module.ptr()),false);
399+
if(module_new)
400+
Terminal::get().print("Python module "+stem + " has been reloaded \n");
401+
else PythonError();
402+
}else{
403+
PythonError();
404+
module=PythonInterpreter::get().import(stem);
405+
if(module)
406+
Terminal::get().print("Python module "+stem + " has been reloaded \n");
407+
}
408+
}
394409
}
395410
if(view->file_path.extension().string()==".py"){
396411
auto file_path=view->file_path;

0 commit comments

Comments
 (0)