Update workspaces.cpp

Fix unchecked string to int conversion of workspace name (which can be a string)
Closes #2501
pull/2507/head
Roberto Previdi 2023-09-13 18:20:13 +02:00 committed by GitHub
parent a90e275d5e
commit 69736d68aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 2 deletions

View File

@ -439,7 +439,6 @@ void Workspaces::sort_workspaces() {
// Helper comparisons
auto is_id_less = a->id() < b->id();
auto is_name_less = a->name() < b->name();
auto is_number_less = std::stoi(a->name()) < std::stoi(b->name());
switch (sort_by_) {
case SORT_METHOD::ID:
@ -448,7 +447,7 @@ void Workspaces::sort_workspaces() {
return is_name_less;
case SORT_METHOD::NUMBER:
try {
return is_number_less;
return std::stoi(a->name()) < std::stoi(b->name());
} catch (const std::invalid_argument &) {
// Handle the exception if necessary.
break;