test(extmarks): improve tests for ui_watched (#26732)

This commit is contained in:
zeertzjq 2023-12-25 15:50:58 +08:00 committed by GitHub
parent 2877672d70
commit a42df11786
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1807,7 +1807,7 @@ describe('API/win_extmark', function()
extmarks = {
[2] = {
-- positioned at the end of the 2nd line
{ {id = 1000}, 1, 1, 1, 16 },
{ {id = 1000}, ns, marks[1], 1, 16 },
}
},
})
@ -1816,6 +1816,7 @@ describe('API/win_extmark', function()
it('sends multiple ui-watched marks to ui', function()
screen = Screen.new(20, 4)
screen:attach()
feed('15A!<Esc>')
-- should send all of these
set_extmark(ns, marks[1], 1, 0, { ui_watched = true, virt_text_pos = "overlay" })
set_extmark(ns, marks[2], 1, 2, { ui_watched = true, virt_text_pos = "overlay" })
@ -1825,25 +1826,34 @@ describe('API/win_extmark', function()
screen:expect({
grid = [[
non ui-watched line |
ui-watched lin^e |
~ |
ui-watched line!!!!!|
!!!!!!!!!^! |
|
]],
extmarks = {
[2] = {
-- earlier notifications
{ {id = 1000}, 1, 1, 1, 0 },
{ {id = 1000}, 1, 1, 1, 0 }, { {id = 1000}, 1, 2, 1, 2 },
{ {id = 1000}, 1, 1, 1, 0 }, { {id = 1000}, 1, 2, 1, 2 }, { {id = 1000}, 1, 3, 1, 4 },
{ {id = 1000}, 1, 1, 1, 0 }, { {id = 1000}, 1, 2, 1, 2 }, { {id = 1000}, 1, 3, 1, 4 }, { {id = 1000}, 1, 4, 1, 6 },
-- notification from 1st call
{ {id = 1000}, ns, marks[1], 1, 0 },
-- notifications from 2nd call
{ {id = 1000}, ns, marks[1], 1, 0 },
{ {id = 1000}, ns, marks[2], 1, 2 },
-- notifications from 3nd call
{ {id = 1000}, ns, marks[1], 1, 0 },
{ {id = 1000}, ns, marks[2], 1, 2 },
{ {id = 1000}, ns, marks[3], 1, 4 },
-- notifications from 4th call
{ {id = 1000}, ns, marks[1], 1, 0 },
{ {id = 1000}, ns, marks[2], 1, 2 },
{ {id = 1000}, ns, marks[3], 1, 4 },
{ {id = 1000}, ns, marks[4], 1, 6 },
-- final
-- overlay
{ {id = 1000}, 1, 1, 1, 0 },
{ {id = 1000}, 1, 2, 1, 2 },
{ {id = 1000}, 1, 3, 1, 4 },
{ {id = 1000}, 1, 4, 1, 6 },
{ {id = 1000}, ns, marks[1], 1, 0 },
{ {id = 1000}, ns, marks[2], 1, 2 },
{ {id = 1000}, ns, marks[3], 1, 4 },
{ {id = 1000}, ns, marks[4], 1, 6 },
-- eol
{ {id = 1000}, 1, 5, 1, 16 },
{ {id = 1000}, ns, marks[5], 2, 11 },
}
},
})
@ -1868,9 +1878,9 @@ describe('API/win_extmark', function()
extmarks = {
[2] = {
-- positioned at the end of the 2nd line
{ {id = 1000}, 1, 1, 1, 16 },
{ {id = 1000}, ns, marks[1], 1, 16 },
-- updated and wrapped to 3rd line
{ {id = 1000}, 1, 1, 2, 2 },
{ {id = 1000}, ns, marks[1], 2, 2 },
}
}
})
@ -1885,9 +1895,9 @@ describe('API/win_extmark', function()
extmarks = {
[2] = {
-- positioned at the end of the 2nd line
{ {id = 1000}, 1, 1, 1, 16 },
{ {id = 1000}, ns, marks[1], 1, 16 },
-- updated and wrapped to 3rd line
{ {id = 1000}, 1, 1, 2, 2 },
{ {id = 1000}, ns, marks[1], 2, 2 },
-- scrolled up one line, should be handled by grid scroll
}
}
@ -1923,13 +1933,13 @@ describe('API/win_extmark', function()
extmarks = {
[2] = {
-- positioned at the end of the 2nd line
{ {id = 1000}, 1, 1, 1, 16 },
{ {id = 1000}, ns, marks[1], 1, 16 },
-- updated after split
{ {id = 1000}, 1, 1, 1, 16 },
{ {id = 1000}, ns, marks[1], 1, 16 },
},
[4] = {
-- only after split
{ {id = 1001}, 1, 1, 1, 16 },
{ {id = 1001}, ns, marks[1], 1, 16 },
}
}
})
@ -1956,14 +1966,14 @@ describe('API/win_extmark', function()
extmarks = {
[2] = {
-- positioned at the end of the 2nd line
{ {id = 1000}, 1, 1, 1, 16 },
{ {id = 1000}, ns, marks[1], 1, 16 },
-- updated after split
{ {id = 1000}, 1, 1, 1, 16 },
{ {id = 1000}, ns, marks[1], 1, 16 },
},
[4] = {
{ {id = 1001}, 1, 1, 1, 16 },
{ {id = 1001}, ns, marks[1], 1, 16 },
-- updated
{ {id = 1001}, 1, 1, 2, 2 },
{ {id = 1001}, ns, marks[1], 2, 2 },
}
}
})