about summary refs log tree commit diff stats
path: root/src/utils/twtstr.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-07-06 02:02:58 +0200
committerbptato <nincsnevem662@gmail.com>2023-07-06 02:02:58 +0200
commitfbeed195b9f0f7df8a0cf7149c815efa5089f13c (patch)
tree60c41d49890f0dcf13355a74b435201cc1115eb0 /src/utils/twtstr.nim
parent4511c956bf62983f1d3f0252805fadaac040123e (diff)
downloadchawan-fbeed195b9f0f7df8a0cf7149c815efa5089f13c.tar.gz
Fix regression in twidth
Diffstat (limited to 'src/utils/twtstr.nim')
-rw-r--r--src/utils/twtstr.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim
index 60b85cbc..77d86998 100644
--- a/src/utils/twtstr.nim
+++ b/src/utils/twtstr.nim
@@ -1068,10 +1068,10 @@ func width*(s: seq[Rune], min: int): int =
     inc i
 
 func twidth*(s: string, w: int): int =
-  var i = 0
+  var i = w
   for r in s.runes():
-    i += r.twidth(result)
-  return i
+    i += r.twidth(w)
+  return i - w
 
 func breaksWord*(r: Rune): bool =
   return not (r.isDigitAscii() or r.width() == 0 or r.isAlpha())