diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-08-05 20:12:43 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-08-05 20:12:43 +0200 |
| commit | 18ca4223061acd32c18a8631673beefc0f4cc1d3 (patch) | |
| tree | 3db1f742895b886434b6686b0516cc0f1a24bbac /src/buffer.cc | |
| parent | 1ce2d3e3022526e0d422fe20c20defbc57bb237d (diff) | |
Context: only buffer context are not allowed, an editor is always needed
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index 13a0a131..f619edb1 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -33,21 +33,23 @@ Buffer::Buffer(String name, Type type, if (not initial_content.empty()) apply_modification(Modification::make_insert(begin(), std::move(initial_content))); + Editor editor_for_hooks(*this); + Context context(editor_for_hooks); if (type == Type::NewFile) - m_hook_manager.run_hook("BufNew", m_name, Context(*this)); + m_hook_manager.run_hook("BufNew", m_name, context); else if (type == Type::File) - m_hook_manager.run_hook("BufOpen", m_name, Context(*this)); + m_hook_manager.run_hook("BufOpen", m_name, context); - m_hook_manager.run_hook("BufCreate", m_name, Context(*this)); + m_hook_manager.run_hook("BufCreate", m_name, context); } Buffer::~Buffer() { + m_hook_manager.run_hook("BufClose", m_name, Context(Editor(*this))); + m_windows.clear(); BufferManager::instance().unregister_buffer(this); assert(m_change_listeners.empty()); - - m_hook_manager.run_hook("BufClose", m_name, Context(*this)); } BufferIterator Buffer::iterator_at(const BufferCoord& line_and_column) const |
