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

fix: set_mode may not be taken into account #596

Merged
merged 1 commit into from
Aug 8, 2024
Merged

Conversation

pipoprods
Copy link
Contributor

I'm using quick-access shortcuts to switch to a given terminal:

			{ "<M-&>", "<cmd>1 ToggleTerm<cr>", mode = { "n", "t" }, desc = "Toggle terminal 1" },
			{ "<M-é>", "<cmd>2 ToggleTerm<cr>", mode = { "n", "t" }, desc = "Toggle terminal 2" },
			{ '<M-">', "<cmd>3 ToggleTerm<cr>", mode = { "n", "t" }, desc = "Toggle terminal 3" },
			{ "<M-'>", "<cmd>4 ToggleTerm<cr>", mode = { "n", "t" }, desc = "Toggle terminal 4" },
			{ "<M-(>", "<cmd>5 ToggleTerm<cr>", mode = { "n", "t" }, desc = "Toggle terminal 5" },
			{ "<M-->", "<cmd>6 ToggleTerm<cr>", mode = { "n", "t" }, desc = "Toggle terminal 6" },
			{ "<M-è>", "<cmd>7 ToggleTerm<cr>", mode = { "n", "t" }, desc = "Toggle terminal 7" },
			{ "<M-_>", "<cmd>8 ToggleTerm<cr>", mode = { "n", "t" }, desc = "Toggle terminal 8" },
			{ "<M-ç>", "<cmd>9 ToggleTerm<cr>", mode = { "n", "t" }, desc = "Toggle terminal 9" },
			{ "<M-à>", "<cmd>10 ToggleTerm<cr>", mode = { "n", "t" }, desc = "Toggle terminal 10" },

With this setup, every time I switch from one terminal to another, the terminal is placed in normal mode.

This PR postpones the set_mode command so the mode gets what is expected.

@akinsho
Copy link
Owner

akinsho commented Aug 8, 2024

🤞🏿 let's hope nothing breaks, thanks for the PR

@akinsho akinsho merged commit 137d06f into akinsho:main Aug 8, 2024
3 of 4 checks passed
@augustocdias
Copy link

I wonder if this is the culprit of some weird behaviors I'm seeing lately... I have an autocmd to set the term in insert mode on BufEnter and that just stopped working. Sometimes it fails to leave insert mode either. All of this is just random. I couldn't figure out yet what triggers these problems.

@pipoprods
Copy link
Contributor Author

pipoprods commented Aug 23, 2024

@augustocdias Did you try postponing your autocmd with a vim.schedule? Does the behavior change?
Could you post a relevant part of your config so I can test it on my side?

@augustocdias
Copy link

@pipoprods this is the toggleterm config:
https://github.com/augustocdias/dotfiles/blob/main/.config/nvim/lua/setup/toggleterm.lua

and those are my autocmds:

https://github.com/augustocdias/dotfiles/blob/main/.config/nvim/lua/setup/autocommand.lua#L2-L32

I can't find a consistent way to reproduce it... I also have an issue sometimes where the term just doesn't leave insert mode... I have to kill it and start it again.

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

Successfully merging this pull request may close these issues.

3 participants