chore: sync
This commit is contained in:
@@ -23,10 +23,10 @@ describe('util.display_height', function()
|
||||
|
||||
-- Unicode width test
|
||||
local u_lines = {
|
||||
'12345678👍', -- 10
|
||||
'あうえお', -- 8
|
||||
'𠮷野い𠮷家野家家', -- 16
|
||||
'👍👍👍お家', -- 10
|
||||
'12345678👍', -- 10
|
||||
'あうえお', -- 8
|
||||
'𠮷野い𠮷家野家家', -- 16
|
||||
'👍👍👍お家', -- 10
|
||||
}
|
||||
|
||||
assert.are.equal(4, util.display_height(u_lines, 20))
|
||||
@@ -82,9 +82,9 @@ describe('util.is_word', function()
|
||||
for test, value in pairs {
|
||||
['あうえお'] = false,
|
||||
['hello'] = true,
|
||||
[' hello'] = false,
|
||||
['hello world'] = false,
|
||||
['test_cool'] = false,
|
||||
[' hello'] = false,
|
||||
} do
|
||||
assert.are.same(util.is_word(test), value)
|
||||
end
|
||||
|
@@ -29,20 +29,24 @@ describe('window', with_buffer(function(buffer)
|
||||
|
||||
describe('smooth_expand', function()
|
||||
it('can work well when no pass animation table', function()
|
||||
window:smooth_expand { field = 'width', to = 10 }
|
||||
assert.are.same(window:width(), 10)
|
||||
|
||||
window:smooth_expand { field = 'width', to = 6 }
|
||||
assert.are.same(window:width(), 6)
|
||||
|
||||
window:smooth_expand { field = 'height', to = 10 }
|
||||
assert.are.same(window:height(), 10)
|
||||
|
||||
window:smooth_expand { field = 'height', to = 6 }
|
||||
assert.are.same(window:height(), 6)
|
||||
|
||||
window:smooth_expand { field = 'height', to = 6 }
|
||||
assert.are.same(window:height(), 6)
|
||||
for field, values in pairs {
|
||||
width = {
|
||||
10,
|
||||
6,
|
||||
8,
|
||||
5,
|
||||
},
|
||||
height = {
|
||||
10,
|
||||
6,
|
||||
3,
|
||||
},
|
||||
} do
|
||||
for _, value in ipairs(values) do
|
||||
window:smooth_expand { field = field, to = value }
|
||||
assert.are.same(value, window[field](window))
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
it("don't change window wrap option", function()
|
||||
@@ -68,4 +72,29 @@ describe('window', with_buffer(function(buffer)
|
||||
window:resize { width = 5, height = 5 }
|
||||
assert.is_true(window:option 'wrap')
|
||||
end)
|
||||
|
||||
it('adjust_height() can auto adjust window height to buffer display height', function()
|
||||
for idx, content in ipairs {
|
||||
'cool',
|
||||
'co10',
|
||||
'家👍',
|
||||
'👍ol',
|
||||
'cあl',
|
||||
'家野',
|
||||
} do
|
||||
buffer[idx] = content
|
||||
end
|
||||
|
||||
local max_height = vim.o.lines - 2
|
||||
for width, expect in ipairs {
|
||||
[2] = 12,
|
||||
[3] = 12,
|
||||
[4] = 6,
|
||||
[5] = 6,
|
||||
} do
|
||||
window:smooth_expand { field = 'width', to = width }
|
||||
window:adjust_height()
|
||||
assert.are.same(math.min(expect, max_height), window:height())
|
||||
end
|
||||
end)
|
||||
end))
|
||||
|
Reference in New Issue
Block a user