diff --git a/RELEASE-NOTES-next b/RELEASE-NOTES-next index e896b54e..c24c82a0 100644 --- a/RELEASE-NOTES-next +++ b/RELEASE-NOTES-next @@ -17,5 +17,4 @@ strongly encouraged to upgrade. │ Bugfixes │ └────────────────────────────┘ - • placeholder - + • when initializing new outputs, avoid duplicating workspace numbers diff --git a/src/workspace.c b/src/workspace.c index f3ddf01c..db3afe4a 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -254,12 +254,15 @@ Con *create_workspace_on_output(Output *output, Con *content) { continue; } - exists = (get_existing_workspace_by_name(target_name) != NULL); + const int num = ws_name_to_number(target_name); + exists = (num == -1) + ? get_existing_workspace_by_name(target_name) + : get_existing_workspace_by_num(num); if (!exists) { ws->name = sstrdup(target_name); /* Set ->num to the number of the workspace, if the name actually * is a number or starts with a number */ - ws->num = ws_name_to_number(ws->name); + ws->num = num; LOG("Used number %d for workspace with name %s\n", ws->num, ws->name); break;