Skip to content

Commit

Permalink
Defer deletion of unsetted option to return to main loop
Browse files Browse the repository at this point in the history
Fixes #2572
  • Loading branch information
mawww committed Jan 20, 2019
1 parent ca105f8 commit ae69759
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/option_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "assert.hh"
#include "flags.hh"
#include "scope.hh"

namespace Kakoune
{
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/option_manager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option>&& option) { m_option_trash.push_back(std::move(option)); }
private:
OptionManager& m_global_manager;
Vector<std::unique_ptr<const OptionDesc>, MemoryDomain::Options> m_descs;
Vector<std::unique_ptr<Option>> m_option_trash;
};

}
Expand Down

0 comments on commit ae69759

Please sign in to comment.