goto-preview
goto-preview copied to clipboard
[BUG] Preview window won't show if "dismiss_on_move = true" and "focus_on_open = true"
Describe the bug
I've set dismiss_on_move = true
but still got the default value focus_on_open = true
But now the preview window won't show anymore / auto closes instantly
If focus_on_open = false
(the cursor is not moved) all works as expected
To Reproduce Steps to reproduce the behavior:
- set config to
dismiss_on_move = true
andfocus_on_open = true
- Try to open a valid goto
- No window shown
Expected behavior Preview window to show dismiss-on-move to have only have an effect if cursor moved in the buffer which the goto is called from
Baseline (please complete the following information):
-
OS:
Linux X 6.2.0-34-generic #34~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 7 13:12:03 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
-
Neovim version:
NVIM v0.9.2-dev
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
my lazy plugin call
{
'rmagatti/goto-preview',
config = function()
require('goto-preview').setup {
debug = true,
default_mappings = true,
dismiss_on_move = true,
}
end
}
- nvim messages:
goto-preview: lib: {
border = { "↖", "─", "┐", "│", "┘", "─", "└", "│" },
bufhidden = "wipe",
debug = true,
default_mappings = true,
dismiss_on_move = true,
focus_on_open = true,
force_close = true,
height = 15,
lsp_configs = {
get_config = <function 1>
},
preview_window_title = {
enable = true,
position = "left"
},
references = {},
resizing_mappings = false,
stack_floating_preview_windows = true,
width = 120
}
goto-preview: calling new handler
goto-preview: data from the lsp {
range = {
["end"] = {
character = 29,
line = 81
},
start = {
character = 11,
line = 81
}
},
uri = "file:///opt/ros/humble/include/nav2_behavior_tree/behavior_tree_engine.hpp"
}
goto-preview: focus_on_open true
goto-preview: stack_floating_preview_windows true
goto-preview: {
bufpos = { 45, 18 },
curr_window = 1002,
get_config = {
anchor = "NW",
border = { "↖", "─", "┐", "│", "┘", "─", "└", "│" },
bufpos = { 45, 18 },
col = {
[false] = 0,
[true] = 3
},
external = false,
focusable = true,
height = 15,
relative = "win",
row = {
[false] = 1,
[true] = 3
},
title = { { "/opt/ros/humble/include/nav2_behavior_tree/behavior_tree_engine.hpp", "FloatTitle" } },
title_pos = "left",
width = 120,
win = 1000,
zindex = 1
},
get_current_line = " BT::Tree createTreeFromFile(",
preview_window = 1002,
windows = { 1002 }
}
goto-preview: dismiss_on_move true
goto-preview: post_open_hook call success: false attempt to call a nil value
goto-preview: dismiss_preview 1002
goto-preview: attempting to close 1002
Additional context Not sure if this counts as a bug, is intended behavior or just a logic error in general on my part 🤷🏻
Hm yeah these options don't really go together. The way dismiss_on_move
works is:
- Open floating window
- On open, set an autocmd on cursor move to dismiss the preview for the given window number
- When autocmd is triggered, dismiss the given floating window.
Now, how focus_on_open
works:
- Open floating window using
vim.api.nvim_open_win
and the "focus" property set to true - The focus property means move the cursor to the new window
The issue:
- Moving the cursor to focus on the floating window that's open triggers the cursor move autocmd, which kicks off the dismiss function.
Essentially, these options are mutually exclusive. I suppose a note in the readme mentioning this might be a good addition.