diff --git a/src/context.hh b/src/context.hh index 86362467..3cfb979c 100644 --- a/src/context.hh +++ b/src/context.hh @@ -32,6 +32,16 @@ struct Context return *m_window; } bool has_window() const { return m_window; } + + OptionManager& option_manager() const + { + if (m_window) + return m_window->option_manager(); + if (m_buffer) + return m_buffer->option_manager(); + return GlobalOptionManager::instance(); + } + public: safe_ptr m_window; safe_ptr m_buffer; diff --git a/src/main.cc b/src/main.cc index c86c33a8..aa084566 100644 --- a/src/main.cc +++ b/src/main.cc @@ -440,7 +440,7 @@ int main(int argc, char* argv[]) { return context.window().selections_content().back(); }); shell_manager.register_env_var("opt_.+", [](const String& name, const Context& context) - { return context.window().option_manager()[name.substr(4)].as_string(); }); + { return context.option_manager()[name.substr(4)].as_string(); }); register_commands(); register_highlighters(); register_filters();