Defer deletion of unsetted option to return to main loop

Fixes #2572
This commit is contained in:
Maxime Coste 2019-01-20 22:46:40 +11:00
parent ca105f8cc6
commit ae69759a53
3 changed files with 7 additions and 0 deletions

View File

@ -759,6 +759,7 @@ int run_server(StringView session, StringView server_init,
client_manager.clear_client_trash(); client_manager.clear_client_trash();
client_manager.clear_window_trash(); client_manager.clear_window_trash();
buffer_manager.clear_buffer_trash(); buffer_manager.clear_buffer_trash();
global_scope.option_registry().clear_option_trash();
if (local_client and not contains(client_manager, local_client)) if (local_client and not contains(client_manager, local_client))
local_client = nullptr; local_client = nullptr;

View File

@ -2,6 +2,7 @@
#include "assert.hh" #include "assert.hh"
#include "flags.hh" #include "flags.hh"
#include "scope.hh"
namespace Kakoune namespace Kakoune
{ {
@ -85,6 +86,7 @@ void OptionManager::unset_option(StringView name)
{ {
auto& parent_option = (*m_parent)[name]; auto& parent_option = (*m_parent)[name];
const bool changed = not parent_option.has_same_value(*it->value); const bool changed = not parent_option.has_same_value(*it->value);
GlobalScope::instance().option_registry().move_to_trash(std::move(it->value));
m_options.erase(name); m_options.erase(name);
if (changed) if (changed)
on_option_changed(parent_option); on_option_changed(parent_option);

View File

@ -263,9 +263,13 @@ public:
bool option_exists(StringView name) const { return option_desc(name) != nullptr; } bool option_exists(StringView name) const { return option_desc(name) != nullptr; }
CandidateList complete_option_name(StringView prefix, ByteCount cursor_pos) const; CandidateList complete_option_name(StringView prefix, ByteCount cursor_pos) const;
void clear_option_trash() { m_option_trash.clear(); }
void move_to_trash(std::unique_ptr<Option>&& option) { m_option_trash.push_back(std::move(option)); }
private: private:
OptionManager& m_global_manager; OptionManager& m_global_manager;
Vector<std::unique_ptr<const OptionDesc>, MemoryDomain::Options> m_descs; Vector<std::unique_ptr<const OptionDesc>, MemoryDomain::Options> m_descs;
Vector<std::unique_ptr<Option>> m_option_trash;
}; };
} }