From ae69759a53b9fcddf4ee2a7b2a5acf40eb62c195 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 20 Jan 2019 22:46:40 +1100 Subject: [PATCH] Defer deletion of unsetted option to return to main loop Fixes #2572 --- src/main.cc | 1 + src/option_manager.cc | 2 ++ src/option_manager.hh | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/src/main.cc b/src/main.cc index 085f9c03..2832c363 100644 --- a/src/main.cc +++ b/src/main.cc @@ -759,6 +759,7 @@ int run_server(StringView session, StringView server_init, client_manager.clear_client_trash(); client_manager.clear_window_trash(); buffer_manager.clear_buffer_trash(); + global_scope.option_registry().clear_option_trash(); if (local_client and not contains(client_manager, local_client)) local_client = nullptr; diff --git a/src/option_manager.cc b/src/option_manager.cc index ea7a1d91..5dd3d612 100644 --- a/src/option_manager.cc +++ b/src/option_manager.cc @@ -2,6 +2,7 @@ #include "assert.hh" #include "flags.hh" +#include "scope.hh" namespace Kakoune { @@ -85,6 +86,7 @@ void OptionManager::unset_option(StringView name) { auto& parent_option = (*m_parent)[name]; 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); if (changed) on_option_changed(parent_option); diff --git a/src/option_manager.hh b/src/option_manager.hh index 372c04d2..77f482c0 100644 --- a/src/option_manager.hh +++ b/src/option_manager.hh @@ -263,9 +263,13 @@ public: bool option_exists(StringView name) const { return option_desc(name) != nullptr; } 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