diff --git a/src/buffer.cc b/src/buffer.cc index 4f792e38..d5cb762c 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -28,7 +28,11 @@ Buffer::Buffer(const std::string& name, Type type, { BufferManager::instance().register_buffer(this); - GlobalHooksManager::instance().run_hook("BufCreate", name, Context(*this)); + if (type == Type::NewFile) + GlobalHooksManager::instance().run_hook("BufCreate", name, Context(*this)); + else if (type == Type::File) + GlobalHooksManager::instance().run_hook("BufOpen", name, Context(*this)); + compute_lines(); } diff --git a/src/buffer.hh b/src/buffer.hh index 3cedffd3..7b010c9b 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -111,6 +111,7 @@ public: enum class Type { File, + NewFile, Scratch }; diff --git a/src/main.cc b/src/main.cc index d0164737..d1a0ae85 100644 --- a/src/main.cc +++ b/src/main.cc @@ -515,7 +515,7 @@ Buffer* open_or_create(const std::string& filename) catch (file_not_found& what) { print_status("new file " + filename); - buffer = new Buffer(filename, Buffer::Type::File); + buffer = new Buffer(filename, Buffer::Type::NewFile); } return buffer; } @@ -554,7 +554,7 @@ void quit(const CommandParameters& params, const Context& context) { for (auto& buffer : BufferManager::instance()) { - if (buffer.type() == Buffer::Type::File and buffer.is_modified()) + if (buffer.type() != Buffer::Type::Scratch and buffer.is_modified()) { print_status("modified buffer remaining"); return;