Do not include non-primitive option value in *SetOption hook filter
Only include the value for int/str/bool options, for the rest just write '<option name>=...'. This should reduce the cost of some patterns such as repeatedly adding a value inside a list option. It seems very unlikely that the actual value would be matched by a hook regex string for non primitive types.
This commit is contained in:
parent
66f15cf4ad
commit
f75d49e9ef
|
@ -16,6 +16,10 @@ released versions.
|
||||||
* `%val{...}` now expands to list of strings, `$kak_quoted_...` now work
|
* `%val{...}` now expands to list of strings, `$kak_quoted_...` now work
|
||||||
as expected with these.
|
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
|
== Kakoune v2020.01.16
|
||||||
|
|
||||||
* Expose history tree through `$kak_history` and
|
* Expose history tree through `$kak_history` and
|
||||||
|
|
|
@ -685,7 +685,7 @@ void Buffer::on_option_changed(const Option& option)
|
||||||
m_flags &= ~Flags::ReadOnly;
|
m_flags &= ~Flags::ReadOnly;
|
||||||
}
|
}
|
||||||
run_hook_in_own_context(Hook::BufSetOption,
|
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)
|
void Buffer::run_hook_in_own_context(Hook hook, StringView param, String client_name)
|
||||||
|
|
|
@ -55,6 +55,7 @@ public:
|
||||||
|
|
||||||
virtual String get_as_string(Quoting quoting) const = 0;
|
virtual String get_as_string(Quoting quoting) const = 0;
|
||||||
virtual Vector<String> get_as_strings() const = 0;
|
virtual Vector<String> get_as_strings() const = 0;
|
||||||
|
virtual String get_desc_string() const = 0;
|
||||||
virtual void set_from_strings(ConstArrayView<String> strs) = 0;
|
virtual void set_from_strings(ConstArrayView<String> strs) = 0;
|
||||||
virtual void add_from_strings(ConstArrayView<String> strs) = 0;
|
virtual void add_from_strings(ConstArrayView<String> strs) = 0;
|
||||||
virtual void update(const Context& context) = 0;
|
virtual void update(const Context& context) = 0;
|
||||||
|
@ -154,6 +155,14 @@ public:
|
||||||
return option_to_string(m_value, quoting);
|
return option_to_string(m_value, quoting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get_desc_string() const override
|
||||||
|
{
|
||||||
|
if constexpr (std::is_same_v<int, T> or std::is_same_v<bool, T> or std::is_same_v<String, T>)
|
||||||
|
return option_to_string(m_value, Quoting::Raw);
|
||||||
|
else
|
||||||
|
return "...";
|
||||||
|
}
|
||||||
|
|
||||||
void set_from_strings(ConstArrayView<String> strs) override
|
void set_from_strings(ConstArrayView<String> strs) override
|
||||||
{
|
{
|
||||||
set(option_from_strings(Meta::Type<T>{}, strs));
|
set(option_from_strings(Meta::Type<T>{}, strs));
|
||||||
|
|
|
@ -19,7 +19,7 @@ void GlobalScope::on_option_changed(const Option& option)
|
||||||
{
|
{
|
||||||
Context empty_context{Context::EmptyContextFlag{}};
|
Context empty_context{Context::EmptyContextFlag{}};
|
||||||
hooks().run_hook(Hook::GlobalSetOption,
|
hooks().run_hook(Hook::GlobalSetOption,
|
||||||
format("{}={}", option.name(), option.get_as_string(Quoting::Raw)),
|
format("{}={}", option.name(), option.get_desc_string()),
|
||||||
empty_context);
|
empty_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -346,8 +346,7 @@ void Window::clear_display_buffer()
|
||||||
|
|
||||||
void Window::on_option_changed(const Option& option)
|
void Window::on_option_changed(const Option& option)
|
||||||
{
|
{
|
||||||
run_hook_in_own_context(Hook::WinSetOption, format("{}={}", option.name(),
|
run_hook_in_own_context(Hook::WinSetOption, format("{}={}", option.name(), option.get_desc_string()));
|
||||||
option.get_as_string(Quoting::Raw)));
|
|
||||||
// an highlighter might depend on the option, so we need to redraw
|
// an highlighter might depend on the option, so we need to redraw
|
||||||
force_redraw();
|
force_redraw();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user