From a7fe81e63e193164ad9f3c4b1f30065e831438b3 Mon Sep 17 00:00:00 2001 From: equalsraf Date: Mon, 5 Feb 2024 14:03:23 +0000 Subject: [PATCH 1/2] Discard resize if already resizing for same size When resizeNeovim() is called we can defer the call for later, but we should never defer a resize if the target size is the same. Otherwise we can end up in a loop with Neovim issuing resize events. --- src/gui/shell.cpp | 22 +++++++++++++++++----- src/gui/shell.h | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/gui/shell.cpp b/src/gui/shell.cpp index 1486b8236..f0372a39c 100644 --- a/src/gui/shell.cpp +++ b/src/gui/shell.cpp @@ -1608,11 +1608,22 @@ void Shell::resizeNeovim(int n_cols, int n_rows) if (!m_nvim || (n_cols == columns() && n_rows == rows())) { return; } - if (m_resizing) { - m_resize_neovim_pending = QSize(n_cols, n_rows); - } else { + + auto newsize = QSize(n_cols, n_rows); + + if (m_resizing.isValid() && m_resizing == newsize) { + // Do not trigger two consecutive resizes for the same size. + // Neovim may fail to resize and issue a resize event that + // would result in a loop + return; + } + + if (m_resizing.isValid()) { + m_resize_neovim_pending = newsize; + } + else { m_nvim->api0()->ui_try_resize(n_cols, n_rows); - m_resizing = true; + m_resizing = newsize; } } @@ -1632,7 +1643,8 @@ void Shell::resizeEvent(QResizeEvent *ev) */ void Shell::neovimResizeFinished() { - m_resizing = false; + m_resizing = QSize(); + if (m_resize_neovim_pending.isValid()) { resizeNeovim(m_resize_neovim_pending.width(), m_resize_neovim_pending.height()); diff --git a/src/gui/shell.h b/src/gui/shell.h index c45fdd4d0..69562dc70 100644 --- a/src/gui/shell.h +++ b/src/gui/shell.h @@ -221,7 +221,7 @@ private slots: /// Neovim mode descriptions from "mode_change", used by guicursor QVariantList m_modeInfo; - bool m_resizing{ false }; + QSize m_resizing; QSize m_resize_neovim_pending; QLabel* m_tooltip{ nullptr }; QPoint m_mouse_pos; From 36c9e7e14055667fec2d86f0743a6c6f9d1adb49 Mon Sep 17 00:00:00 2001 From: equalsraf Date: Wed, 7 Feb 2024 07:42:13 +0000 Subject: [PATCH 2/2] Bump CI runner for macos-12 --- .github/workflows/build-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index f0a335267..f2ac33bcb 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -37,10 +37,10 @@ jobs: - name: MacOS_GCC flavor: Debug - runner: macos-11 + runner: macos-12 generator: Ninja - cc: gcc-10 - cxx: g++-10 + cc: gcc-11 + cxx: g++-11 - name: MacOS_Release flavor: Release