aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/ui')
-rw-r--r--test/functional/ui/cursor_spec.lua2
-rw-r--r--test/functional/ui/decorations_spec.lua238
-rw-r--r--test/functional/ui/messages_spec.lua16
-rw-r--r--test/functional/ui/screen.lua2
-rw-r--r--test/functional/ui/sign_spec.lua30
5 files changed, 182 insertions, 106 deletions
diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua
index 8bfceb8cce..f7eb8394bd 100644
--- a/test/functional/ui/cursor_spec.lua
+++ b/test/functional/ui/cursor_spec.lua
@@ -250,7 +250,7 @@ describe('ui/cursor', function()
m.attr = { background = Screen.colors.DarkGray }
end
if m.id_lm then
- m.id_lm = 69
+ m.id_lm = 71
end
end
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 746bfb3262..318dc8c197 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -5497,6 +5497,26 @@ l5
api.nvim_buf_clear_namespace(0, ns, 0, -1)
end)
+
+ it([[correct numberwidth with 'signcolumn' set to "number" #28984]], function()
+ command('set number numberwidth=1 signcolumn=number')
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { sign_text = 'S1' })
+ screen:expect({
+ grid = [[
+ S1 ^ |
+ {1:~ }|*8
+ |
+ ]]
+ })
+ api.nvim_buf_del_extmark(0, ns, 1)
+ screen:expect({
+ grid = [[
+ {8:1 }^ |
+ {1:~ }|*8
+ |
+ ]]
+ })
+ end)
end)
describe('decorations: virt_text', function()
@@ -5575,20 +5595,26 @@ describe('decorations: virt_text', function()
end)
describe('decorations: window scoped', function()
- local screen, ns
+ local screen, ns, win_other
local url = 'https://example.com'
before_each(function()
clear()
screen = Screen.new(20, 10)
screen:attach()
screen:add_extra_attr_ids {
- [100] = { special = Screen.colors.Red, undercurl = true },
- [101] = { url = "https://example.com" },
+ [100] = { special = Screen.colors.Red, undercurl = true },
+ [101] = { url = 'https://example.com' },
}
ns = api.nvim_create_namespace 'test'
insert('12345')
+
+ win_other = api.nvim_open_win(0, false, {
+ col=0,row=0,width=20,height=10,
+ relative = 'win',style = 'minimal',
+ hide = true
+ })
end)
local noextmarks = {
@@ -5596,28 +5622,28 @@ describe('decorations: window scoped', function()
1234^5 |
{1:~ }|*8
|
- ]]}
+ ]],
+ }
- local function set_scoped_extmark(line, col, opts)
- return api.nvim_buf_set_extmark(0, ns, line, col, vim.tbl_extend('error', { scoped = true }, opts))
+ local function set_extmark(line, col, opts)
+ return api.nvim_buf_set_extmark(0, ns, line, col, opts)
end
it('hl_group', function()
- set_scoped_extmark(0, 0, {
+ set_extmark(0, 0, {
hl_group = 'Comment',
end_col = 3,
})
- screen:expect(noextmarks)
-
- api.nvim__win_add_ns(0, ns)
+ api.nvim__ns_set(ns, { wins = { 0 } })
screen:expect {
grid = [[
{18:123}4^5 |
{1:~ }|*8
|
- ]]}
+ ]],
+ }
command 'split'
command 'only'
@@ -5626,48 +5652,55 @@ describe('decorations: window scoped', function()
end)
it('virt_text', function()
- set_scoped_extmark(0, 0, {
+ set_extmark(0, 0, {
virt_text = { { 'a', 'Comment' } },
virt_text_pos = 'eol',
})
- set_scoped_extmark(0, 5, {
+ set_extmark(0, 5, {
virt_text = { { 'b', 'Comment' } },
virt_text_pos = 'inline',
})
- set_scoped_extmark(0, 1, {
+ set_extmark(0, 1, {
virt_text = { { 'c', 'Comment' } },
virt_text_pos = 'overlay',
})
- set_scoped_extmark(0, 1, {
+ set_extmark(0, 1, {
virt_text = { { 'd', 'Comment' } },
virt_text_pos = 'right_align',
})
- screen:expect(noextmarks)
-
- api.nvim__win_add_ns(0, ns)
+ api.nvim__ns_set(ns, { wins = { 0 } })
screen:expect {
grid = [[
1{18:c}34^5{18:b} {18:a} {18:d}|
{1:~ }|*8
|
- ]]}
+ ]],
+ }
command 'split'
command 'only'
screen:expect(noextmarks)
+
+ api.nvim__ns_set(ns, { wins = {} })
+
+ screen:expect {
+ grid = [[
+ 1{18:c}34^5{18:b} {18:a} {18:d}|
+ {1:~ }|*8
+ |
+ ]],
+ }
end)
it('virt_lines', function()
- set_scoped_extmark(0, 0, {
+ set_extmark(0, 0, {
virt_lines = { { { 'a', 'Comment' } } },
})
- screen:expect(noextmarks)
-
- api.nvim__win_add_ns(0, ns)
+ api.nvim__ns_set(ns, { wins = { 0 } })
screen:expect {
grid = [[
@@ -5675,7 +5708,8 @@ describe('decorations: window scoped', function()
{18:a} |
{1:~ }|*7
|
- ]]}
+ ]],
+ }
command 'split'
command 'only'
@@ -5684,14 +5718,12 @@ describe('decorations: window scoped', function()
end)
it('redraws correctly with inline virt_text and wrapping', function()
- set_scoped_extmark(0, 2, {
- virt_text = {{ ('b'):rep(18), 'Comment' }},
- virt_text_pos = 'inline'
+ set_extmark(0, 2, {
+ virt_text = { { ('b'):rep(18), 'Comment' } },
+ virt_text_pos = 'inline',
})
- screen:expect(noextmarks)
-
- api.nvim__win_add_ns(0, ns)
+ api.nvim__ns_set(ns, { wins = { 0 } })
screen:expect {
grid = [[
@@ -5699,9 +5731,10 @@ describe('decorations: window scoped', function()
34^5 |
{1:~ }|*7
|
- ]]}
+ ]],
+ }
- api.nvim__win_del_ns(0, ns)
+ api.nvim__ns_set(ns, { wins = { win_other } })
screen:expect(noextmarks)
end)
@@ -5709,21 +5742,20 @@ describe('decorations: window scoped', function()
pending('sign_text', function()
-- TODO(altermo): The window signcolumn width is calculated wrongly (when `signcolumn=auto`)
-- This happens in function `win_redraw_signcols` on line containing `buf_meta_total(buf, kMTMetaSignText) > 0`
- set_scoped_extmark(0, 0, {
+ set_extmark(0, 0, {
sign_text = 'a',
sign_hl_group = 'Comment',
})
- screen:expect(noextmarks)
-
- api.nvim__win_add_ns(0, ns)
+ api.nvim__ns_set(ns, { wins = { 0 } })
screen:expect {
grid = [[
a 1234^5 |
{2:~ }|*8
|
- ]]}
+ ]],
+ }
command 'split'
command 'only'
@@ -5732,30 +5764,34 @@ describe('decorations: window scoped', function()
end)
it('statuscolumn hl group', function()
- set_scoped_extmark(0, 0, {
- number_hl_group='comment',
+ set_extmark(0, 0, {
+ number_hl_group = 'comment',
})
- set_scoped_extmark(0, 0, {
- line_hl_group='comment',
+ set_extmark(0, 0, {
+ line_hl_group = 'comment',
})
command 'set number'
+ api.nvim__ns_set(ns, { wins = { win_other } })
+
screen:expect {
grid = [[
{8: 1 }1234^5 |
{1:~ }|*8
|
- ]]}
+ ]],
+ }
- api.nvim__win_add_ns(0, ns)
+ api.nvim__ns_set(ns, { wins = { 0 } })
screen:expect {
grid = [[
{18: 1 1234^5 }|
{1:~ }|*8
|
- ]]}
+ ]],
+ }
command 'split'
command 'only'
@@ -5765,36 +5801,43 @@ describe('decorations: window scoped', function()
{8: 1 }1234^5 |
{1:~ }|*8
|
- ]]}
+ ]],
+ }
end)
it('spell', function()
- api.nvim_buf_set_lines(0,0,-1,true,{'aa'})
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'aa' })
- set_scoped_extmark(0, 0, {
- spell=true,
- end_col=2,
+ set_extmark(0, 0, {
+ spell = true,
+ end_col = 2,
})
command 'set spelloptions=noplainbuffer'
command 'set spell'
command 'syntax off'
+ screen:expect({ unchanged = true })
+
+ api.nvim__ns_set(ns, { wins = { win_other } })
+
screen:expect {
grid = [[
a^a |
{1:~ }|*8
|
- ]]}
+ ]],
+ }
- api.nvim__win_add_ns(0, ns)
+ api.nvim__ns_set(ns, { wins = { 0 } })
screen:expect {
grid = [[
{100:a^a} |
{1:~ }|*8
|
- ]]}
+ ]],
+ }
command 'split'
command 'only'
@@ -5804,25 +5847,25 @@ describe('decorations: window scoped', function()
a^a |
{1:~ }|*8
|
- ]]}
+ ]],
+ }
end)
it('url', function()
- set_scoped_extmark(0, 0, {
- end_col=3,
- url=url,
+ set_extmark(0, 0, {
+ end_col = 3,
+ url = url,
})
- screen:expect(noextmarks)
-
- api.nvim__win_add_ns(0, ns)
+ api.nvim__ns_set(ns, { wins = { 0 } })
screen:expect {
grid = [[
{101:123}4^5 |
{1:~ }|*8
|
- ]]}
+ ]],
+ }
command 'split'
command 'only'
@@ -5830,85 +5873,72 @@ describe('decorations: window scoped', function()
screen:expect(noextmarks)
end)
- it('change extmarks scoped option', function()
- local id = set_scoped_extmark(0, 0, {
+ it('change namespace scope', function()
+ set_extmark(0, 0, {
hl_group = 'Comment',
end_col = 3,
})
- api.nvim__win_add_ns(0, ns)
+ api.nvim__ns_set(ns, { wins = { 0 } })
+ eq({ wins={ api.nvim_get_current_win() } }, api.nvim__ns_get(ns))
screen:expect {
grid = [[
{18:123}4^5 |
{1:~ }|*8
|
- ]]}
+ ]],
+ }
command 'split'
command 'only'
screen:expect(noextmarks)
- api.nvim_buf_set_extmark(0, ns, 0, 0, {
- id = id,
- hl_group = 'Comment',
- end_col = 3,
- scoped = false,
- })
+ api.nvim__ns_set(ns, { wins = { 0 } })
+ eq({ wins={ api.nvim_get_current_win() } }, api.nvim__ns_get(ns))
screen:expect {
grid = [[
{18:123}4^5 |
{1:~ }|*8
|
- ]]}
+ ]],
+ }
- api.nvim_buf_set_extmark(0, ns, 0, 0, {
- id = id,
- hl_group = 'Comment',
- end_col = 3,
- scoped = true,
+ local win_new = api.nvim_open_win(0, false, {
+ col=0,row=0,width=20,height=10,
+ relative = 'win',style = 'minimal',
+ hide = true
})
+ api.nvim__ns_set(ns, { wins = { win_new } })
+ eq({ wins={ win_new } }, api.nvim__ns_get(ns))
+
screen:expect(noextmarks)
end)
- it('change namespace scope', function()
- set_scoped_extmark(0, 0, {
- hl_group = 'Comment',
- end_col = 3,
- })
+ it('namespace get works', function()
+ eq({ wins = {} }, api.nvim__ns_get(ns))
- eq(true, api.nvim__win_add_ns(0, ns))
- eq({ ns }, api.nvim__win_get_ns(0))
+ api.nvim__ns_set(ns, { wins = { 0 } })
- screen:expect {
- grid = [[
- {18:123}4^5 |
- {1:~ }|*8
- |
- ]]}
+ eq({ wins = { api.nvim_get_current_win() } }, api.nvim__ns_get(ns))
- command 'split'
- command 'only'
- eq({}, api.nvim__win_get_ns(0))
+ api.nvim__ns_set(ns, { wins = {} })
- screen:expect(noextmarks)
+ eq({ wins = {} }, api.nvim__ns_get(ns))
+ end)
- eq(true, api.nvim__win_add_ns(0, ns))
- eq({ ns }, api.nvim__win_get_ns(0))
+ it('remove window from namespace scope when deleted', function ()
+ api.nvim__ns_set(ns, { wins = { 0 } })
- screen:expect {
- grid = [[
- {18:123}4^5 |
- {1:~ }|*8
- |
- ]]}
+ eq({ wins = { api.nvim_get_current_win() } }, api.nvim__ns_get(ns))
- eq(true, api.nvim__win_del_ns(0, ns))
- eq({}, api.nvim__win_get_ns(0))
+ command 'split'
+ command 'only'
- screen:expect(noextmarks)
+ eq({ wins = {} }, api.nvim__ns_get(ns))
end)
end)
+
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index ca52a265fa..07192800e5 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -1081,6 +1081,22 @@ stack traceback:
},
})
end)
+
+ it('does not do showmode unnecessarily #29086', function()
+ local screen_showmode = screen._handle_msg_showmode
+ local showmode = 0
+ screen._handle_msg_showmode = function(...)
+ screen_showmode(...)
+ showmode = showmode + 1
+ end
+ screen:expect({
+ grid = [[
+ ^ |
+ {1:~ }|*4
+ ]],
+ })
+ eq(showmode, 1)
+ end)
end)
describe('ui/builtin messages', function()
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index f8e95f7d88..932ddb070a 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -438,7 +438,7 @@ end
--- @field mouse_enabled? boolean
---
--- @field win_viewport? table<integer,table<string,integer>>
---- @field float_pos? {[1]:integer,[2]:integer}
+--- @field float_pos? [integer,integer]
--- @field hl_groups? table<string,integer>
---
--- The following keys should be used to expect the state of various ext_
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)