Closed notEvil closed 1 year ago
to clarify, is the issue that we need to make a distinction between visual and visual-block mode?
No, the issue wouldn't exist if visual mode would be cancelled like pressing Escape. I don't know if this is expected behavior, and where it originates (legendary, telescope or even neovim).
I'm still not sure I entirely understand what the issue is precisely.
I'll try to be more precise. Consider the function provided above. If entering Legendary from linewise visual mode, it is in characterwise visual mode when the function is executed. The reason is that somehow visual mode is aborted in a way that doesn't set the marks and the mode. This is different from the usual behavior where leaving visual mode using Escape will set the marks and the mode, so gv
can recreate the visual selection. Since this is not the case, you end up with the correct marks because you get them yourself using get_marks
, and set them before executing the function. However, the mode is lost and gv
uses the mode that was last used (defaults to v
).
I've not seen a single function that aborts visual mode in such a way, and would assume that its a bug, somewhere. In any case, the mode is important.
Ah, yes, I think I get it now, thanks for elaborating. Part of the issue here is that vim.ui.select()
I think always exits visual mode, and doesn’t seem to set marks when doing so, so I’ve got some workarounds in the code to try to set them manually.
there may be a better way to do this, like exiting visual mode purposefully in a way that does properly set the marks before attempting to call vim.ui.select()
.
I’ll do some research.
Hmm, I'm unable to reproduce. Is this not the intended behavior?
You have to start Legendary from a visual mode that wasn't the last. So the most precise steps are:
Then, the mode will change back to characterwise.
If the mode in 1 matches the one in 3, you don't see the effect.
Similar Issues
Neovim Version
Steps to Reproduce
V
)require('legendary').find()
Expected Behavior
Selection is still linewise
Actual Behavior
Selection is per character (
v
)Minimal Configuration to Reproduce
Output from :LegendaryLog
``` [Mi 21 Jun 2023 13:04:15 CEST][legendary.nvim] Preparing to execute selected item [Mi 21 Jun 2023 13:04:15 CEST][legendary.nvim] Performing SQL transaction with following data: { params = { where = { item_id = "':LegendaryLog
output (click to expand)Additional Details and/or Screenshots
I narrowed the issue down to:
https://github.com/mrjones2014/legendary.nvim/blob/6a3b2411146432f83ef44c7980d7a2b20f7a39ce/lua/legendary/ui/init.lua#L82 seems to hard abort visual mode (unlike pressing Escape) and the subsequent https://github.com/mrjones2014/legendary.nvim/blob/6a3b2411146432f83ef44c7980d7a2b20f7a39ce/lua/legendary/api/executor.lua#L40 doesn't use the correct mode.
Workaround: before calling
require('legendary').find()
, execute<esc>gv