Support quitting while executing RuntimeError hooks

Fixes #529
This commit is contained in:
Maxime Coste 2015-12-14 19:06:30 +00:00
parent 6873a44e3e
commit d2b0dba39d
2 changed files with 29 additions and 23 deletions

View File

@ -65,6 +65,8 @@ void Client::handle_available_input(EventMode mode)
return;
}
try
{
try
{
while (Optional<Key> key = get_next_key(mode))
@ -86,6 +88,7 @@ void Client::handle_available_input(EventMode mode)
context().print_status({ error.what().str(), get_face("Error") });
context().hooks().run_hook("RuntimeError", error.what(), context());
}
}
catch (Kakoune::client_removed& removed)
{
ClientManager::instance().remove_client(*this, removed.graceful);

View File

@ -40,6 +40,8 @@ Client* ClientManager::create_client(std::unique_ptr<UserInterface>&& ui,
std::move(ws.selections), std::move(env_vars),
generate_name()};
m_clients.emplace_back(client);
try
{
try
{
CommandManager::instance().execute(init_commands, client->context());
@ -50,6 +52,7 @@ Client* ClientManager::create_client(std::unique_ptr<UserInterface>&& ui,
client->context().hooks().run_hook("RuntimeError", error.what(),
client->context());
}
}
catch (Kakoune::client_removed& removed)
{
remove_client(*client, removed.graceful);