dispatchers: support number as arg in changegroupactive (#3329)

This commit is contained in:
memchr 2023-09-23 12:36:40 +00:00 committed by GitHub
parent 8637bfb1b7
commit 8252957392
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1172,6 +1172,18 @@ void CKeybindManager::changeGroupActive(std::string args) {
if (PWINDOW->m_sGroupData.pNextWindow == PWINDOW) if (PWINDOW->m_sGroupData.pNextWindow == PWINDOW)
return; 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") { if (args != "b" && args != "prev") {
PWINDOW->setGroupCurrent(PWINDOW->m_sGroupData.pNextWindow); PWINDOW->setGroupCurrent(PWINDOW->m_sGroupData.pNextWindow);
} else { } else {