diff --git a/src/buffer.cc b/src/buffer.cc index d5cb762c2..f7f7ff553 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -243,6 +243,11 @@ void Buffer::delete_window(Window* window) m_windows.erase(window_it); } +std::unique_ptr Buffer::create_temporary_window() +{ + return std::unique_ptr(new Window(*this)); +} + bool Buffer::is_modified() const { size_t history_cursor_index = m_history_cursor - m_history.begin(); diff --git a/src/buffer.hh b/src/buffer.hh index 7b010c9bd..d9649cbbf 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -151,6 +151,8 @@ public: Window* get_or_create_window(); void delete_window(Window* window); + std::unique_ptr create_temporary_window(); + bool is_modified() const; Type type() const { return m_type; } void notify_saved(); diff --git a/src/main.cc b/src/main.cc index d1a0ae85c..686dec64e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1048,6 +1048,12 @@ void exec_string(const CommandParameters& params, return keys[pos++]; }; + std::unique_ptr temp_window; + if (not context.has_window()) + temp_window = context.buffer().create_temporary_window(); + + Window& window = context.has_window() ? context.window() : *temp_window; + int count = 0; while(pos < keys.size()) { @@ -1059,7 +1065,7 @@ void exec_string(const CommandParameters& params, { auto it = keymap.find(key); if (it != keymap.end()) - it->second(context.window(), count); + it->second(window, count); count = 0; } }