From 82529573929178a71e1e65bd315950c1e179254e Mon Sep 17 00:00:00 2001 From: memchr <118117622+memchr@users.noreply.github.com> Date: Sat, 23 Sep 2023 12:36:40 +0000 Subject: [PATCH] dispatchers: support number as arg in changegroupactive (#3329) --- src/managers/KeybindManager.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 0e4d47b9..1a7ebafc 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1172,6 +1172,18 @@ void CKeybindManager::changeGroupActive(std::string args) { if (PWINDOW->m_sGroupData.pNextWindow == PWINDOW) return; + if (isNumber(args, false)) { + // index starts from '1'; '0' means last window + const int INDEX = std::stoi(args); + if (INDEX > PWINDOW->getGroupSize()) + return; + if (INDEX == 0) + PWINDOW->setGroupCurrent(PWINDOW->getGroupTail()); + else + PWINDOW->setGroupCurrent(PWINDOW->getGroupWindowByIndex(INDEX - 1)); + return; + } + if (args != "b" && args != "prev") { PWINDOW->setGroupCurrent(PWINDOW->m_sGroupData.pNextWindow); } else {