diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2024-06-10 16:55:16 +0200 |
---|---|---|
committer | Luuk van Baal <luukvbaal@gmail.com> | 2024-06-10 20:00:59 +0200 |
commit | 1dcda865591b9bdda2fec1a1860efb4df56ea533 (patch) | |
tree | 881b423a64bd4d2a9e6f4170c9115a2a1e73d67b /test/functional/ui/sign_spec.lua | |
parent | d9af8c2431b7c6395abece8104be6a47d6f61f39 (diff) | |
download | rneovim-1dcda865591b9bdda2fec1a1860efb4df56ea533.tar.gz rneovim-1dcda865591b9bdda2fec1a1860efb4df56ea533.tar.bz2 rneovim-1dcda865591b9bdda2fec1a1860efb4df56ea533.zip |
fix(column): clamp line number for legacy signs
Problem: Legacy :sign API still allows placing signs beyond the end of
the buffer. This is unaccounted for by the signcolumn tracking
logic and is disallowed in general for the extmark API which
implements it now.
Solution: Clamp legacy sign line number to the length of the buffer.
Diffstat (limited to 'test/functional/ui/sign_spec.lua')
-rw-r--r-- | test/functional/ui/sign_spec.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua index b353b3738a..6f4bf5695d 100644 --- a/test/functional/ui/sign_spec.lua +++ b/test/functional/ui/sign_spec.lua @@ -577,4 +577,34 @@ describe('Signs', function() ]]) eq({}, eval('sign_getdefined()')) end) + + it('no crash when unplacing signs beyond end of buffer', function() + exec([[ + sign define S1 text=S1 + sign define S2 text=S2 + sign place 1 line=8 name=S1 + sign place 2 line=9 name=S2 + ]]) + -- Now placed at end of buffer + local s1 = { + grid = [[ + S2^ | + {0:~ }|*12 + | + ]], + } + screen:expect(s1) + -- Signcolumn tracking used to not count signs placed beyond end of buffer here + exec('set signcolumn=auto:9') + screen:expect({ + grid = [[ + S2S1^ | + {0:~ }|*12 + | + ]], + }) + -- Unplacing the sign does not crash by decrementing tracked signs below zero + exec('sign unplace 1') + screen:expect(s1) + end) end) |