From 9787756619c47beb189d7bc14623d86e88516e8c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 8 Sep 2023 05:24:11 +1000 Subject: [PATCH] Use last display setup instead of recomputing for window_range Fixes #4964 --- src/main.cc | 2 +- src/window.cc | 1 + src/window.hh | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.cc b/src/main.cc index db0fb5f4..7752bc66 100644 --- a/src/main.cc +++ b/src/main.cc @@ -385,7 +385,7 @@ static const EnvVarDesc builtin_env_vars[] = { { "window_range", false, [](StringView name, const Context& context) -> Vector { - auto setup = context.window().compute_display_setup(context); + const auto& setup = context.window().last_display_setup(); return {format("{} {} {} {}", setup.first_line, setup.first_column, setup.line_count, 0)}; } diff --git a/src/window.cc b/src/window.cc index b660bbdb..41e34767 100644 --- a/src/window.cc +++ b/src/window.cc @@ -155,6 +155,7 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context) set_position({setup.first_line, setup.first_column}); m_last_setup = build_setup(context); + m_last_display_setup = setup; return m_display_buffer; } diff --git a/src/window.hh b/src/window.hh index 2b96cb70..65253c87 100644 --- a/src/window.hh +++ b/src/window.hh @@ -49,10 +49,12 @@ public: void clear_display_buffer(); void run_resize_hook_ifn(); - DisplaySetup compute_display_setup(const Context& context) const; + const DisplaySetup& last_display_setup() const { return m_last_display_setup; } + private: Window(const Window&) = delete; + DisplaySetup compute_display_setup(const Context& context) const; void on_option_changed(const Option& option) override; friend class ClientManager; @@ -68,6 +70,7 @@ private: Highlighters m_builtin_highlighters; bool m_resize_hook_pending = false; + DisplaySetup m_last_display_setup; struct Setup {