-
Notifications
You must be signed in to change notification settings - Fork 24
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
When toggling terminal, cursor jumps from a different buffer to minimap buffer #106
Comments
I can confirm this happens with several prompts. |
Im to dumb of a vim user to know if there even is a way of changing that. Can someone help? |
Can you attempt the same test with a regular split window open (via |
Here is a very simple asciinema of the problem with vsplits |
Apologies I was unclear, I meant a split without the minimap. I want to see if the minimap autocmds are grabbing the cursor, or if vim is putting the cursor in the right window when it's finished with the 'nofile' floating window. |
OH sorry, yes sure |
Ok, so the minimap is for sure changing the behavior. This probably has to do with the buffer ordering. When you enter a new window, the minimap does stuff, which I think puts it as the 'last used' buffer, so it would be the target when the terminal window exits. We will have to play around with this to confirm. |
Nice guys! Tell me if I can help |
Is search highlighting enabled in these examples? |
Yes it is, and it is a little bit weird this time now that I switched it off. |
same issue with After plugin's float window is closed , curror will be moved to minimap!!! |
Yes, I can confirm this behavior with vim-floaterm. |
Apologies this is taking a long time to track down. I've done some investigating work, but this is a bug that is arising partly from some intrinsic vimisms around buffers/windows. The 'fix' will not really be a fix, but a workaround. I'm still planning to track this down, but it's not as easy as I had hoped, nor have I had as much time to work on it as I have wanted. |
The problem I'm seeing is that the floating window is not being reported as a separate window (it doesn't increment Beyond that, the documentation for floating windows is very slim. Floating windows seem to have different behaviors than normal windows, but the behavior is not documented well, if at all. If you never navigate via the minimap (i.e. the only time your cursor ends up in there, it's a mistake/bug), then you might consider adding a custom autocmd:
^ Not checked, but something like that might work |
Put this code inside your
|
Haven't done much vim / neovim / lua stuff, but here's my lua attempt at making it go back to the same window you were in before the floating window was opened. local lastaccessed
vim.api.nvim_create_autocmd({'WinEnter'}, {
callback = function()
local minimapname = '-MINIMAP-'
if string.sub(vim.api.nvim_buf_get_name(0), -string.len(minimapname)) == minimapname then
local wins = vim.api.nvim_list_wins()
vim.api.nvim_set_current_win(lastaccessed)
else
lastaccessed = vim.api.nvim_eval("win_getid(winnr('#'))")
end
end
}) |
It seems that this issue has been going on for quite some time. In NVIM, I did this: local pre_window
local float_leave = false
vim.api.nvim_create_autocmd({ "WinEnter", "BufLeave" }, {
callback = function(event)
if event.event == "BufLeave" then
if event.file == '' and event.match == '' then
float_leave = true
end
elseif event.event == "WinEnter" then
local minimap_name = '-MINIMAP-'
if string.sub(event.file, -string.len(minimap_name)) == minimap_name and string.sub(event.match, -string.len(minimap_name)) == minimap_name and float_leave then
vim.api.nvim_set_current_win(pre_window)
else
pre_window = vim.fn.win_getid(vim.fn.winnr('#'))
end
float_leave = false
end
end
}) The main function is to record when the exiting window is a floating window, and if MINIMAP is entered immediately. |
Hi, confirm this is still happening, any updates on fixing this? |
I'm not sure this issue is able to be resolved in a way that is satisfactory to all use cases. If one of the workarounds is not acceptable for your use case, minimap.vim may just be incompatible with floating-window style plugins unless there's some changes to how floating windows are handled (see my previous comment) |
Check list
Environment info
Version info
Question / Problem and steps to reproduce
When opening a terminal with
toggleterm
, when I close the terminal (the keybinding isctrl
+t
for toggling the terminal), the cursor jumps from a previous buffer to the minimap buffer, which is very annoying as I have to move the cursor back between buffers each time I use a terminal in vim.2021-09-20.00-22-24.mp4
The text was updated successfully, but these errors were encountered: