about summary refs log tree commit diff stats
path: root/src/layout/engine.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/layout/engine.nim')
-rw-r--r--src/layout/engine.nim8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim
index 93a324b3..0377dbb0 100644
--- a/src/layout/engine.nim
+++ b/src/layout/engine.nim
@@ -677,10 +677,10 @@ proc processWhitespace(ictx: var InlineContext, state: var InlineState,
     if c == '\n':
       ictx.flushLine(state)
     elif c == '\t':
-      let prev = ictx.currentLine.charwidth
-      ictx.currentLine.charwidth = ((ictx.currentLine.charwidth +
-        ictx.whitespacenum) div 8 + 1) * 8 - ictx.whitespacenum
-      ictx.whitespacenum += ictx.currentLine.charwidth - prev
+      let realWidth = ictx.currentLine.charwidth + ictx.whitespacenum
+      let targetTabStops = realWidth div 8 + 1
+      let targetWidth = targetTabStops * 8
+      ictx.whitespacenum += targetWidth - realWidth
       ictx.whitespaceFragment = state.fragment
     else:
       inc ictx.whitespacenum