tpope / vim-dadbod

dadbod.vim: Modern database interface for Vim
https://www.vim.org/scripts/script.php?script_id=5665
3.73k stars 132 forks source link

:DB hangs in GVim when attempting to open interactive console #51

Open dexterous opened 5 years ago

dexterous commented 5 years ago

Per README, if only connection URL is provided and SQL string / file is omitted, it should spawn an interactive console. However, when executed in GVim, the Vim just locks up.

I have tpope/vim-dispatch installed and running...

Start postgresql://...

... does open psql in interactive mode (albeit) within the Ex bar.

With a little experimentation, I found that taking off the silent at https://github.com/tpope/vim-dadbod/blob/master/autoload/db.vim#L206

silent execute 'Start' escape(cmd, '%#')

... does the trick.

tpope commented 5 years ago

That's unexpected. Does :silent Start cmd.exe lock up the same way?

vadz commented 5 days ago

FWIW this bug is still present when using the current version (i.e. fe5a55e (Add Snowflake support (#174), 2024-10-18)) with gvim 9.0.1677 under Unix.

Removing silent fixes it.

tpope commented 5 days ago

If it's the Start line causing it, it's probably a dispatch.vim issue. When you delete the silent to make it work, what adapter does it use?

vadz commented 5 days ago

Sorry for being clueless, but how do I find out which adapter is used, exactly?

tpope commented 4 days ago

What happens when you run it?

vadz commented 4 days ago

If I run it without changing the plugin, GVim just hangs, with :DB sqlite3://... in the command line and nothing else happening until I (blindly) type .q<Enter>, after which it gets back to normal mode (Ctrl-C doesn't work).

If I remove silent, it shows SQLite prompt which I can use more or less normally (except the usual readline keys don't work).

FWIW I think I'm not using any adapter at all, i.e. exists(':Start:') returns 0 for me.

tpope commented 4 days ago

FWIW I think I'm not using any adapter at all, i.e. exists(':Start:') returns 0 for me.

Is that a typo? The correct check is exists(':Start').

vadz commented 4 days ago

FWIW I think I'm not using any adapter at all, i.e. exists(':Start:') returns 0 for me.

Is that a typo? The correct check is exists(':Start').

Yes, sorry, this was indeed a typo, I've checked the correct command.

Rereading all this now, I think there was a misunderstanding: I've tried using :DB after installing this plugin and was surprised that it hung and went looking for an existing issue and found this one, which seemed very similar, but it looks like it's not the same thing: this one is about :Start not working as intended, apparently, while my problem is that silent '!... doesn't show anything — which is, AFAIK, perfectly normal.

I.e. I believe my problem is addressed by just

diff --git a/autoload/db.vim b/autoload/db.vim
index a89a6db..56bb2a9 100644
--- a/autoload/db.vim
+++ b/autoload/db.vim
@@ -470,7 +470,7 @@ function! db#execute_command(mods, bang, line1, line2, cmd) abort
       if exists(':Start') == 2
         silent execute 'Start' escape(cmd, '%#')
       else
-        silent execute '!'.escape(cmd, '!%#')
+        execute '!'.escape(cmd, '!%#')
         redraw!
       endif
     else

Sorry for the confusion.

tpope commented 4 days ago

Okay, yeah, distinct issue but possibly with the same cause. I bet this is contingent on whether or not 'guioptions' contains !.

vadz commented 4 days ago

You're right, my guioptions is set to r and adding ! to it lets :DB work even with silent, thanks!