From 938f66badd711d74cef467fdf33096f82c62df23 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 30 Jan 2014 12:01:19 +0000 Subject: Check for buffer external change when entering insert mode --- src/input_handler.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/input_handler.cc') diff --git a/src/input_handler.cc b/src/input_handler.cc index 904ce420..d511c3fe 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -26,7 +26,8 @@ public: InputMode& operator=(const InputMode&) = delete; virtual void on_key(Key key) = 0; - virtual void on_replaced() {} + virtual void on_enabled() {} + virtual void on_disabled() {} Context& context() const { return m_input_handler.context(); } virtual String description() const = 0; @@ -62,11 +63,19 @@ public: context().client().check_buffer_fs_timestamp(); timer.set_next_date(Clock::now() + fs_check_timeout); }} + {} + + void on_enabled() override { + if (not context().has_client()) + return; + context().client().check_buffer_fs_timestamp(); + m_fs_check_timer.set_next_date(Clock::now() + fs_check_timeout); + context().hooks().run_hook("NormalBegin", "", context()); } - void on_replaced() override + void on_disabled() override { context().hooks().run_hook("NormalEnd", "", context()); } @@ -1141,7 +1150,7 @@ private: buffer.check_invariant(); } - void on_replaced() override + void on_disabled() override { for (auto& sel : context().selections()) { @@ -1177,9 +1186,10 @@ InputHandler::~InputHandler() void InputHandler::change_input_mode(InputMode* new_mode) { - m_mode->on_replaced(); + m_mode->on_disabled(); m_mode_trash.emplace_back(std::move(m_mode)); m_mode.reset(new_mode); + new_mode->on_enabled(); } void InputHandler::insert(InsertMode mode) -- cgit v1.2.3