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

Commit 2b63cea

Browse files
committed
bugfix: make sure to only load plugins within the plugin folder
1 parent 8dc1fbd commit 2b63cea

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/window.cc

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -329,18 +329,23 @@ void Window::set_menu_actions() {
329329
Notebook::get().get_view(c)->configure();
330330
Notebook::get().configure(c);
331331
}
332-
if(view->file_path>Config::get().python.plugin_directory){
333-
auto stem=view->file_path.stem().string();
334-
auto module=Python::get_loaded_module(stem);
335-
module=module ? Python::reload(module) : Python::import(stem);
336-
if(module)
337-
Terminal::get().print("Plugin `"+stem+"` was reloaded\n");
338-
else {
339-
if(Python::thrown_exception_matches(Python::Error::Type::Syntax))
340-
Terminal::get().print(Python::SyntaxError());
341-
else
342-
Terminal::get().print(Python::Error());
332+
auto file_path=view->file_path;
333+
while(file_path.has_parent_path()){
334+
if(file_path == Config::get().python.plugin_directory){
335+
auto stem=file_path.stem().string();
336+
auto module=Python::get_loaded_module(stem);
337+
module=module ? Python::reload(module) : Python::import(stem);
338+
if(module)
339+
Terminal::get().print("Plugin `"+stem+"` was reloaded\n");
340+
else {
341+
if(Python::thrown_exception_matches(Python::Error::Type::Syntax))
342+
Terminal::get().print(Python::SyntaxError());
343+
else
344+
Terminal::get().print(Python::Error());
345+
}
346+
break;
343347
}
348+
file_path=file_path.parent_path();
344349
}
345350
}
346351
}

0 commit comments

Comments
 (0)