From 97cc16688526065d2b0d39fe0fb5cf7f26ea2642 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 16 Nov 2015 13:52:33 +0000 Subject: [PATCH] Try to restore the previously opened buffer when converting to client mode Fixes #483 --- src/main.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.cc b/src/main.cc index ba372954..42424325 100644 --- a/src/main.cc +++ b/src/main.cc @@ -245,6 +245,7 @@ void register_options() struct convert_to_client_mode { String session; + String buffer_name; }; static Client* local_client = nullptr; @@ -532,6 +533,8 @@ int run_server(StringView session, StringView init_command, if (convert_to_client_pending) { + String buffer_name = local_client->context().buffer().name(); + ClientManager::instance().remove_client(*local_client, true); convert_to_client_pending = false; @@ -539,7 +542,7 @@ int run_server(StringView session, StringView init_command, { String session = server.session(); server.close_session(false); - throw convert_to_client_mode{ std::move(session) }; + throw convert_to_client_mode{ std::move(session), std::move(buffer_name) }; } } } @@ -736,7 +739,9 @@ int main(int argc, char* argv[]) catch (convert_to_client_mode& convert) { raise(SIGTSTP); - return run_client(convert.session, "echo converted to client only mode"); + return run_client(convert.session, + format("try %^buffer '{}'^; echo converted to client only mode", + escape(convert.buffer_name, "'^", '\\'))); } } }