From 12a64bd3d68cc1cf3449d7692150cc820012443a Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Thu, 3 Nov 2016 15:43:45 +0100 Subject: [PATCH] fix(i3): Trim workspace names Closes #126 --- src/modules/i3.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/i3.cpp b/src/modules/i3.cpp index d85afa44..aab176c1 100644 --- a/src/modules/i3.cpp +++ b/src/modules/i3.cpp @@ -119,14 +119,14 @@ namespace modules { string wsname{workspace->name}; - if (m_strip_wsnumbers) { - auto index = string_util::split(wsname, ':'); + // Remove workspace numbers "0:" + if (m_strip_wsnumbers) + wsname.erase(0, string_util::find_nth(wsname, 0, ":", 1) + 1); - if (index.size() == 2) { - wsname = index[1]; - } - } + // Trim leading and trailing whitespace + wsname = string_util::trim(wsname, ' '); + // Cap at configured max length if (m_wsname_maxlen > 0 && wsname.length() > m_wsname_maxlen) wsname.erase(m_wsname_maxlen);