Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how do i reset the window size from the last time #143

Open
HUAHUAI23 opened this issue Oct 3, 2022 · 3 comments
Open

how do i reset the window size from the last time #143

HUAHUAI23 opened this issue Oct 3, 2022 · 3 comments

Comments

@HUAHUAI23
Copy link

2022-10-03-18-33-02.mp4
@mbbill
Copy link
Owner

mbbill commented Oct 5, 2022

The undotree window will remember its width so that you don't have to resize it (e.g. when the line width is not long enough to show all the info) every time you bring it up. In this case when you close the file tree the undotree window gets resized automatically. Although it might not be the intention of the user, that's the default behavior of vim.
You can try to manually resize the undotree window with mouse or resizing command but if you need the panel to restore to its original size even after it gets automatically resized, you may try to hack the plugin to add some resizing autocommand on some events like bufenter.

@arihans
Copy link

arihans commented Oct 18, 2022

@HUAHUAI23 can you please post the solution if you come up with anything.

@HUAHUAI23
Copy link
Author

HUAHUAI23 commented Nov 5, 2022

i solved this

local api = vim.api

local function setUndotreeWinSize()
	local winList = api.nvim_list_wins()
	for _, winHandle in ipairs(winList) do
		if
			api.nvim_win_is_valid(winHandle)
			and api.nvim_buf_get_option(api.nvim_win_get_buf(winHandle), "filetype") == "undotree"
		then
			api.nvim_win_set_width(winHandle, vim.g.undotree_SplitWidth)
		end
	end
end
api.nvim_create_user_command("Ut", function()
	api.nvim_cmd(api.nvim_parse_cmd("UndotreeToggle", {}), {})
	setUndotreeWinSize()
end, { desc = "load undotree" })

wrap UndotreeToggle command with mine,it will set undotree window size

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants