mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
Merge pull request #21702 from glepnir/fix_2
fix(api): convert title_pos string in nvim_win_get_config
This commit is contained in:
@@ -299,7 +299,15 @@ Dictionary nvim_win_get_config(Window window, Error *err)
|
|||||||
ADD(titles, ARRAY_OBJ(tuple));
|
ADD(titles, ARRAY_OBJ(tuple));
|
||||||
}
|
}
|
||||||
PUT(rv, "title", ARRAY_OBJ(titles));
|
PUT(rv, "title", ARRAY_OBJ(titles));
|
||||||
PUT(rv, "title_pos", INTEGER_OBJ(config->title_pos));
|
char *title_pos;
|
||||||
|
if (config->title_pos == kAlignLeft) {
|
||||||
|
title_pos = "left";
|
||||||
|
} else if (config->title_pos == kAlignCenter) {
|
||||||
|
title_pos = "center";
|
||||||
|
} else {
|
||||||
|
title_pos = "right";
|
||||||
|
}
|
||||||
|
PUT(rv, "title_pos", CSTR_TO_OBJ(title_pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1739,6 +1739,28 @@ describe('float window', function()
|
|||||||
}))
|
}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('validate title_pos in nvim_win_get_config', function()
|
||||||
|
local title_pos = exec_lua([[
|
||||||
|
local bufnr = vim.api.nvim_create_buf(false, false)
|
||||||
|
local opts = {
|
||||||
|
relative = 'editor',
|
||||||
|
col = 2,
|
||||||
|
row = 5,
|
||||||
|
height = 2,
|
||||||
|
width = 9,
|
||||||
|
border = 'double',
|
||||||
|
title = 'Test',
|
||||||
|
title_pos = 'center'
|
||||||
|
}
|
||||||
|
|
||||||
|
local win_id = vim.api.nvim_open_win(bufnr, true, opts)
|
||||||
|
return vim.api.nvim_win_get_config(win_id).title_pos
|
||||||
|
]])
|
||||||
|
|
||||||
|
eq('center', title_pos)
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
it('border with title', function()
|
it('border with title', function()
|
||||||
local buf = meths.create_buf(false, false)
|
local buf = meths.create_buf(false, false)
|
||||||
meths.buf_set_lines(buf, 0, -1, true, {' halloj! ',
|
meths.buf_set_lines(buf, 0, -1, true, {' halloj! ',
|
||||||
|
Reference in New Issue
Block a user