about summary refs log tree commit diff stats
path: root/adapter/protocol/man.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-19 11:57:04 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-19 11:57:04 +0100
commit93c1178fe825d5a6144153a11b16c63559f0a8d9 (patch)
tree085d7f058f9b1228de71b3117ef9937e4783a022 /adapter/protocol/man.nim
parent97666a677f9e3cc0296eb97d510ff40ea2c83234 (diff)
downloadchawan-93c1178fe825d5a6144153a11b16c63559f0a8d9.tar.gz
man: improve processBackspace underscore handling
it is best to base our interpretation of ^H_ on the current formatting,
because a) it works predictably well on man output and b) a formatting
mismatch results in manRe malfunctioning
Diffstat (limited to 'adapter/protocol/man.nim')
-rw-r--r--adapter/protocol/man.nim8
1 files changed, 6 insertions, 2 deletions
diff --git a/adapter/protocol/man.nim b/adapter/protocol/man.nim
index 326f3cc1..cc6b9cf9 100644
--- a/adapter/protocol/man.nim
+++ b/adapter/protocol/man.nim
@@ -68,10 +68,14 @@ func processBackspace(line: string): string =
         thiscs = i ..< i + n
         pendingInU = true
       elif line[i] == '_' and line[thiscs.a] == '_':
-        if pendingInB:
+        if inB and not pendingInB:
+          pendingInB = true
+        elif inU and not pendingInU:
           pendingInU = true
-        else:
+        elif not pendingInB:
           pendingInB = true
+        else:
+          pendingInU = true
       elif not pendingInB:
         pendingInB = true
       bspace = false