equalsraf / neovim-qt

Neovim client library and GUI, in Qt5.
https://github.com/equalsraf/neovim-qt/wiki
ISC License
1.85k stars 171 forks source link

Drag and drop file to a non-active buffer's window #928

Open zoumi opened 3 years ago

zoumi commented 3 years ago

OS: Windows 10

It's wired that neovim-qt always open file in active buffer window even though I drop the file to another buffer window.

jgehrig commented 3 years ago

@zoumi

Do you have more details? I'd like to understand what specific steps you are doing, and the platform you are running.

I'm not sure which is happening:

  1. If you're looking for custom drag-drop behavior, you can write a custom handler in VimScrpt GuiDropCustomHandler.
  2. If drag on one window triggers a buffer open in a different window, please provide more details. I will investigate.
zoumi commented 3 years ago

The steps: 1,Open file1.txt and file2.txt with two split windows. 2,Make file1.txt buffer as the active buffer. 3,Drag file_drop.txt to file2.txt buffer. You can see that file_drop.txt is opened in file1.txt buffer. drop

zoumi commented 3 years ago

OS: Windows 10 64bit NVIM: NVIM v0.6.0-dev+218-g3f526feeb

jgehrig commented 3 years ago

Thanks for the detailed steps. I wouldn't have guessed this scenario from your original description.

I'm not sure of a good way to fix this?

Unfortunately, neovim-qt doesn't have any information about window splits or the selected buffer. We're just a dumb rendering canvas that displays a grid of characters. To fix this properly, we would require information internal to nvim.


One potential idea:

We could trigger a single mouse click event at the drag-drop location before we trigger the open command.

I think that would select the current split before triggering the open, fixing this specific issue.

However, the approach could have side-effects. We'd need to think carefully and test exhaustively. Seems hacky.

jgehrig commented 3 years ago

Patch: patch.txt

No quite working... The mouse event is processed after the drop is handled. Darn!

We could add a small delay but that is very hacky.

Furkanzmc commented 3 years ago

I think that would select the current split before triggering the open, fixing this specific issue. However, the approach could have side-effects. We'd need to think carefully and test exhaustively. Seems hacky.

I don't think this would work if the user has mouse support off. Correct? @jgehrig

jgehrig commented 3 years ago

@Furkanzmc

Yes. Although if you have disabled mouse support, I would also expect Drag-Drop to be disabled too. (Not currently the case, probably would fix when/if I make these changes).

pdfrod commented 4 months ago

I was trying to migrate to Neovim Qt from GVim, and I was surprised by the fact that a drag & dropped file didn't open in the buffer that I dropped it in. I don't know how they do it, but this works correctly in GVim.