diff --git a/doc/pages/changelog.asciidoc b/doc/pages/changelog.asciidoc index da087bd2..dda227a8 100644 --- a/doc/pages/changelog.asciidoc +++ b/doc/pages/changelog.asciidoc @@ -16,6 +16,10 @@ released versions. * `%val{...}` now expands to list of strings, `$kak_quoted_...` now work as expected with these. +* `*SetOption` hooks filter string will contain a value only for options + of int/str/bool types to avoid performance issue with generating those + on more complex option types. + == Kakoune v2020.01.16 * Expose history tree through `$kak_history` and diff --git a/src/buffer.cc b/src/buffer.cc index d84586cd..ddbad72c 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -685,7 +685,7 @@ void Buffer::on_option_changed(const Option& option) m_flags &= ~Flags::ReadOnly; } run_hook_in_own_context(Hook::BufSetOption, - format("{}={}", option.name(), option.get_as_string(Quoting::Raw))); + format("{}={}", option.name(), option.get_desc_string())); } void Buffer::run_hook_in_own_context(Hook hook, StringView param, String client_name) diff --git a/src/option_manager.hh b/src/option_manager.hh index 81f3b1b9..739ec6bd 100644 --- a/src/option_manager.hh +++ b/src/option_manager.hh @@ -55,6 +55,7 @@ public: virtual String get_as_string(Quoting quoting) const = 0; virtual Vector get_as_strings() const = 0; + virtual String get_desc_string() const = 0; virtual void set_from_strings(ConstArrayView strs) = 0; virtual void add_from_strings(ConstArrayView strs) = 0; virtual void update(const Context& context) = 0; @@ -154,6 +155,14 @@ public: return option_to_string(m_value, quoting); } + String get_desc_string() const override + { + if constexpr (std::is_same_v or std::is_same_v or std::is_same_v) + return option_to_string(m_value, Quoting::Raw); + else + return "..."; + } + void set_from_strings(ConstArrayView strs) override { set(option_from_strings(Meta::Type{}, strs)); diff --git a/src/scope.cc b/src/scope.cc index 79da998c..64bcd445 100644 --- a/src/scope.cc +++ b/src/scope.cc @@ -19,7 +19,7 @@ void GlobalScope::on_option_changed(const Option& option) { Context empty_context{Context::EmptyContextFlag{}}; hooks().run_hook(Hook::GlobalSetOption, - format("{}={}", option.name(), option.get_as_string(Quoting::Raw)), + format("{}={}", option.name(), option.get_desc_string()), empty_context); } diff --git a/src/window.cc b/src/window.cc index 8acc7a03..ab885ca9 100644 --- a/src/window.cc +++ b/src/window.cc @@ -346,8 +346,7 @@ void Window::clear_display_buffer() void Window::on_option_changed(const Option& option) { - run_hook_in_own_context(Hook::WinSetOption, format("{}={}", option.name(), - option.get_as_string(Quoting::Raw))); + run_hook_in_own_context(Hook::WinSetOption, format("{}={}", option.name(), option.get_desc_string())); // an highlighter might depend on the option, so we need to redraw force_redraw(); }