about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-02-11 17:11:33 +0100
committerbptato <nincsnevem662@gmail.com>2024-02-11 17:11:33 +0100
commit1d97cd35ba0848ced58732fe430fa0db018701e5 (patch)
treeaf7ec4be60db1323c3bb662f8c576df390f330ef /src
parente6c81a12d2234f76b2a49efe14a29fa248ed1499 (diff)
downloadchawan-1d97cd35ba0848ced58732fe430fa0db018701e5.tar.gz
container: fix cursorToggleSelection on double-width characters
Diffstat (limited to 'src')
-rw-r--r--src/local/container.nim7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/local/container.nim b/src/local/container.nim
index 770297f4..d4d44b0f 100644
--- a/src/local/container.nim
+++ b/src/local/container.nim
@@ -1233,18 +1233,19 @@ proc cursorToggleSelection(container: Container, n = 1,
       container.highlights.delete(i)
     container.currentSelection = nil
   else:
+    let cx = container.cursorFirstX()
     let n = n - 1
+    container.cursorRight(n)
     let hl = Highlight(
       t: HL_SELECT,
       selectionType: opts.selectionType,
-      x1: container.cursorx,
+      x1: cx,
       y1: container.cursory,
-      x2: container.cursorx + n,
+      x2: container.cursorx,
       y2: container.cursory
     )
     container.highlights.add(hl)
     container.currentSelection = hl
-    container.cursorRight(n)
   container.triggerEvent(UPDATE)
   return container.currentSelection