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

Using the FZF UIs removes the current visual selection #74

Closed
Penaz91 opened this issue Nov 27, 2022 · 3 comments
Closed

Using the FZF UIs removes the current visual selection #74

Penaz91 opened this issue Nov 27, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@Penaz91
Copy link

Penaz91 commented Nov 27, 2022

Describe the bug
While trying to make a quick menu for nvim's LSP, I ran into the following issue: if you select some text and open vim.ui.* using dressing, the visual selection is lost.

System information

  • OS: Linux
  • Neovim version: 0.8.1
  • Is this related to a specific vim.ui.select backend? If so, which one? Tested on vim.ui.select and vim.ui.input
  • Dressing config:
require("dressing").setup{}

To Reproduce
Steps to reproduce the behavior:

  1. Open a file containing some text
  2. Select some text in visual mode (I usually use line-selection out of habit)
  3. Trigger vim.ui in any way, the most "minimal code" i can provide is the following command
:'<,'>lua vim.ui.input({}, function(item) print(item) end)  
  1. As soon as the ui pops up, the visual selection is lost.

Additional context
I tried disabling the plugin and using the native vim.ui.select and the selection is kept.

I'm using the fzf backend with ibhagwan/fzf-lua.

I'm available for any question!

@Penaz91 Penaz91 added the bug Something isn't working label Nov 27, 2022
@stevearc
Copy link
Owner

Unfortunately, this is just how vim works. When you open fzf, that puts your cursor inside of a terminal window in insert mode (technically, in "terminal" mode). There's no way to also have your cursor be in the original window with a visual mode selection. You could potentially save the current visual selection before calling vim.ui.select, or you could restore the selection after vim.ui.select completes with vim.cmd.normal({args = {"gv"}}), but there's no way to preserve that visual selection while doing anything else with your cursor.

@Penaz91
Copy link
Author

Penaz91 commented Nov 28, 2022

I understand. I thought it was an issue because the normal vim.ui seemed to keep the visual selection "active in background" (although probably only visually) and restore it after the task was completed.

Thank you for the clarification, feel free to close this ticket!

@stevearc
Copy link
Owner

The built-in vim.ui methods use synchronous input functions that block Neovim. All other rendering is paused while waiting for input() or inputlist(). This can be helpful if you really do need the user to input something before you continue execution, but you'll want to manually use vim.fn.inputlist if that's what you're after, since vim.ui.select is designed to work async.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants