about summary refs log tree commit diff stats
path: root/src/utils/twtstr.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-14 13:20:38 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-14 13:20:38 +0100
commit781ac333e503b72d5d6070af02269164806cc597 (patch)
treed07b69ba824d42be7c0fdbb0b8e0d18ed82a9d96 /src/utils/twtstr.nim
parent2eb56a4ae5f86ae0485abbf3a7ab0b1bd50dfe98 (diff)
downloadchawan-781ac333e503b72d5d6070af02269164806cc597.tar.gz
twtstr: fix deleteChars, do not remove space in replaceControls
Diffstat (limited to 'src/utils/twtstr.nim')
-rw-r--r--src/utils/twtstr.nim12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim
index fb77c807..6f40ae7b 100644
--- a/src/utils/twtstr.nim
+++ b/src/utils/twtstr.nim
@@ -611,28 +611,28 @@ proc expandPath*(path: string): string =
         return $p.pw_dir / path.substr(usr.len)
     return path
 
-func deleteChars*(s: string, todel: set[char]): string =
+func deleteChars*(s: string; todel: set[char]): string =
   var i = 0
   block earlyret:
-    for j in 0 ..< s.len:
-      if s[j] in todel:
+    for j, c in s:
+      if c in todel:
         i = j
         break earlyret
     return s
   var rs = newStringOfCap(s.len - 1)
   for j in 0 ..< i:
-    rs[j] = s[j]
+    rs &= s[j]
   for j in i + 1 ..< s.len:
     if s[j] in todel:
       continue
-    rs[i] = s[j]
+    rs &= s[j]
     inc i
   return rs
 
 func replaceControls*(s: string): string =
   result = newStringOfCap(s.len)
   for c in s:
-    if c in Controls:
+    if c in Controls - {' '}:
       result &= '^'
       result &= c.getControlLetter()
     else: