diff options
| author | Maxime Coste <mawww@kakoune.org> | 2025-05-23 10:14:09 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2025-05-23 10:14:09 +1000 |
| commit | d5fc4454551d4d9ee462d1291057a016fbfe3882 (patch) | |
| tree | 56d7e0a943490f36298e0cd0137b8527283d788b /src | |
| parent | b0f541aae65c06f828245e6f90a40967f8e98322 (diff) | |
Disable BufSetOption hook during buffer registration
The hook is manually triggred at the end of registration, by
disabling it we avoid the hook being potentially called multiple
times due to interaction with other hooks.
Fixes #5324
Diffstat (limited to 'src')
| -rw-r--r-- | src/buffer.cc | 6 | ||||
| -rw-r--r-- | src/buffer.hh | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index f0205c54..9a735aaf 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -70,6 +70,8 @@ void Buffer::on_registered() return; } + m_flags |= Flags::NoBufSetOption; + run_hook_in_own_context(Hook::BufCreate, m_name); if (m_flags & Flags::File) @@ -82,6 +84,7 @@ void Buffer::on_registered() run_hook_in_own_context(Hook::BufOpenFile, m_name); } } + m_flags &= ~Flags::NoBufSetOption; for (auto& option : options().flatten_options() | transform(&std::unique_ptr<Option>::get) @@ -637,6 +640,9 @@ const FsStatus& Buffer::fs_status() const void Buffer::on_option_changed(const Option& option) { + if (m_flags & Flags::NoBufSetOption) + return; + if (option.name() == "readonly") { if (option.get<bool>()) diff --git a/src/buffer.hh b/src/buffer.hh index cd895c17..3a885ec8 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -120,6 +120,7 @@ public: NoHooks = 1 << 4, Debug = 1 << 5, ReadOnly = 1 << 6, + NoBufSetOption = 1 << 7, }; friend constexpr bool with_bit_ops(Meta::Type<Flags>) { return true; } friend class BufferIterator; |
