fix(Workspaces): index

This commit is contained in:
Alex 2019-02-02 12:07:59 +01:00
parent add9e925f4
commit 93173851d3
1 changed files with 9 additions and 3 deletions

View File

@ -228,9 +228,15 @@ std::string waybar::modules::sway::Workspaces::getNextWorkspace()
uint16_t waybar::modules::sway::Workspaces::getWorkspaceIndex(const std::string &name) uint16_t waybar::modules::sway::Workspaces::getWorkspaceIndex(const std::string &name)
{ {
for (uint16_t i = 0; i < workspaces_.size(); i += 1) { uint16_t idx = 0;
if (workspaces_[i]["name"].asString() == name) { for (const auto &workspace : workspaces_) {
return i; if (workspace["name"].asString() == name) {
return idx;
}
if (!config_["all-outputs"].asBool() && workspace["output"].asString() != bar_.output_name) {
// Nothing here
} else {
idx += 1;
} }
} }
return workspaces_.size(); return workspaces_.size();