From d6d81607ed7f977e8f66dc5adb145d868b22d69b Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 5 Jun 2015 13:11:04 +0100 Subject: [PATCH] Gracefully handle reloading a file that was deleted --- src/client.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/client.cc b/src/client.cc index a7d3b59aa..6de433b9f 100644 --- a/src/client.cc +++ b/src/client.cc @@ -173,10 +173,15 @@ void Client::reload_buffer() { auto& buffer = context().buffer(); kak_assert(buffer.flags() & Buffer::Flags::File); - Buffer* buf = create_buffer_from_file(buffer.name()); - kak_assert(buf == &buffer); - context().print_status({ format("'{}' reloaded", buffer.display_name()), - get_face("Information") }); + if (Buffer* buf = create_buffer_from_file(buffer.name())) + { + kak_assert(buf == &buffer); + context().print_status({ format("'{}' reloaded", buffer.display_name()), + get_face("Information") }); + } + else + context().print_status({ format("could not reload '{}'", buffer.display_name()), + get_face("Error") }); } void Client::on_buffer_reload_key(Key key)