Describe the bug
We cannot open a popup terminal until after VimEnter has been fired.
To Reproduce
Run this shell command:
vim -Nu NORC -c 'call term_start(&shell, #{hidden: 1})->popup_create({})'
E994 is raised:
E994: Not allowed in a popup window
Expected behavior
No error is raised.
Environment
Additional context
The issue comes from these lines in the netrw plugin:
:windo and :wincmd try to temporarily change the currently focused window, which is disallowed while a popup terminal is active.
In practice, it causes this kind of issues: junegunn/fzf.vim#1231.
This patch should fix the issue:
diff --git a/runtime/plugin/netrwPlugin.vim b/runtime/plugin/netrwPlugin.vim index 217a7795c..6083af0ce 100644 --- a/runtime/plugin/netrwPlugin.vim +++ b/runtime/plugin/netrwPlugin.vim @@ -151,10 +151,8 @@ endfun " has already been called. fun! s:VimEnter(dirname) " call Dfunc("s:VimEnter(dirname<".a:dirname.">) expand(%)<".expand("%").">") - let curwin = winnr() let s:vimentered = 1 - windo call s:LocalBrowse(expand("%:p")) - exe curwin."wincmd w" + call range(1, winnr('$'))->map({_, v -> win_execute(win_getid(v), 'call expand("%:p")->s:LocalBrowse()')}) " call Dret("s:VimEnter") endfun
It uses win_execute() which has fewer side-effects.
cc @cecamp
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
We cannot open a popup terminal until after VimEnter has been fired.
Actually, we can, but it still raises E994.
Can anybody validate @lacygoill's patch?
I was able to apply the patch from @lacygoill and it does indeed resolve the "cannot open a popup prior to VimEnter" issue.
With the patch, I am able to run:
vim -c "Ag foo" directly which results in a popup window opening correctly as expected, whereas without the patch this will throw an exception:
Error detected while processing VimEnter Autocommands for "*"..function <SNR>50_VimEnter:
line 4:
E994: Not allowed in a popup window
Press ENTER or type command to continue
and I have to resort to hacks like:
vim -c "autocmd VimEnter * call timer_start(0, {->execute('Ag foo')})" to get it to work.
@michaelorr : Thanks for testing!
Meanwhile I have built vim from source with this patch applied and I can confirm that it works as expected (tested with vim -c "RgRaw netrw").
@lacygoill : Would you mind creating a pull request with your patch?
I assigned to @cecamp.
Fixed in the last update of the runtime files: 89a9c15
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
![]()
Closed #7742.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.