diff options
author | bptato <nincsnevem662@gmail.com> | 2024-08-15 21:54:08 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-08-15 21:54:08 +0200 |
commit | ad66c25c72ce2b2ae43e3d7a848836fdea4ee572 (patch) | |
tree | 5b2d0caa30e10432846e3692d3dfb87f22d86582 /src/server/buffer.nim | |
parent | 2b8c31f9a504103ce90fe26f6c16412a85cdd9c5 (diff) | |
download | chawan-ad66c25c72ce2b2ae43e3d7a848836fdea4ee572.tar.gz |
buffer: fix some hover weirdness
Setting the new hover value before unsetting the previous one would unset the new hover value for nodes in the same branch. In particular, this broke hover when moving the cursor from a pseudo element (e.g. ::before) to its parent.
Diffstat (limited to 'src/server/buffer.nim')
-rw-r--r-- | src/server/buffer.nim | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/server/buffer.nim b/src/server/buffer.nim index f92d8174..9370f90b 100644 --- a/src/server/buffer.nim +++ b/src/server/buffer.nim @@ -855,7 +855,7 @@ proc updateHover*(buffer: Buffer; cursorx, cursory: int): UpdateHoverResult {.proxy.} = if cursory >= buffer.lines.len: return UpdateHoverResult() - var thisnode: StyledNode + var thisnode: StyledNode = nil let i = buffer.lines[cursory].findFormatN(cursorx) - 1 if i >= 0: thisnode = buffer.lines[cursory].formats[i].node @@ -864,22 +864,22 @@ proc updateHover*(buffer: Buffer; cursorx, cursory: int): UpdateHoverResult let prevnode = buffer.prevnode if thisnode != prevnode and (thisnode == nil or prevnode == nil or thisnode.node != prevnode.node): - for styledNode in thisnode.branch: + for styledNode in prevnode.branch: if styledNode.t == stElement and styledNode.node != nil: let elem = Element(styledNode.node) - if not elem.hover: - elem.setHover(true) + if elem.hover: + elem.setHover(false) repaint = true for ht in HoverType: let s = HoverFun[ht](buffer, thisnode) if buffer.hoverText[ht] != s: hover.add((ht, s)) buffer.hoverText[ht] = s - for styledNode in prevnode.branch: + for styledNode in thisnode.branch: if styledNode.t == stElement and styledNode.node != nil: let elem = Element(styledNode.node) - if elem.hover: - elem.setHover(false) + if not elem.hover: + elem.setHover(true) repaint = true if repaint: buffer.reshape() |