about summary refs log tree commit diff stats
path: root/src/server
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-02-08 23:42:11 +0100
committerbptato <nincsnevem662@gmail.com>2024-02-08 23:44:40 +0100
commit431fd101705146f2d4baaa1a4a139adf356188ab (patch)
tree002fdfecce7eab209f76a36467023bc0f761b125 /src/server
parenta37af56817baa9c6fa1d0ecb6c1800222cf086bb (diff)
downloadchawan-431fd101705146f2d4baaa1a4a139adf356188ab.tar.gz
buffer: fix index defect in updateHover
Caused by a race condition when updateHover is executed after
buffer.lines.len changed in buffer but before the change has been
reported to container.
Diffstat (limited to 'src/server')
-rw-r--r--src/server/buffer.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/server/buffer.nim b/src/server/buffer.nim
index cbefc5a2..e5cdf50d 100644
--- a/src/server/buffer.nim
+++ b/src/server/buffer.nim
@@ -661,7 +661,8 @@ type UpdateHoverResult* = object
   repaint*: bool
 
 proc updateHover*(buffer: Buffer, cursorx, cursory: int): UpdateHoverResult {.proxy.} =
-  if buffer.lines.len == 0: return
+  if cursory >= buffer.lines.len:
+    return
   var thisnode: StyledNode
   let i = buffer.lines[cursory].findFormatN(cursorx) - 1
   if i >= 0: