Open liuyangzys opened 1 year ago
I have the same issue.
I was having the same issue and I think it has to do with an internal race on how the cursor position handling occurs when switching windows.
Adding this to my config to override the default goto_location
handling has locally resolved the issue for me. I just don't know if its the right approach to fixing it.
Plugin.opts = {
keymaps = { -- These keymaps can be a string or a table for multiple keys
goto_location = {},
},
}
Plugin.config = function(_, opts)
require("symbols-outline").setup(opts)
vim.api.nvim_create_autocmd("FileType", {
pattern = "Outline",
callback = function()
vim.keymap.set("n", "<CR>", function()
local outline = require("symbols-outline")
local node = outline._current_node()
vim.api.nvim_win_set_cursor(outline.state.code_win, { node.line + 1, node.character })
vim.schedule(function()
vim.fn.win_gotoid(outline.state.code_win)
end)
end, { buffer = true })
end,
})
end
The key seems to be deferring win_gotoid
just enough.
Same issue here, if it helps, I'm using the plugin in combination with LazyVim.
nvim version 0.9.0
when I press to goto the location of a symbol, if the symbols is not in the field of view, the cursor jump to a wrong place