[vim/vim] netrw: Unexpected behaviour when g:loaded_netrwPlugin is set to 1 (#1246)

60 views
Skip to first unread message

Martin Vuille

unread,
Nov 10, 2016, 8:17:20 PM11/10/16
to vim/vim

Scenario 1

To reproduce:

  • Open vim to empty buffer
  • :Explore, open file 1
  • :Explore, open file 2
  • Ctrl-^

Expected result: switch to file 1's buffer
Actual result: E23: No alternate file

Scenario 2

  • Open vim to empty buffer
  • :edit file 1
  • :edit file 2
  • :Explore, then :Rexplore to exit the file browser
  • Ctrl-^

Expected result: switch to file 1's buffer
Actual result: switch to netrw browser buffer


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Martin Vuille

unread,
Nov 10, 2016, 8:31:22 PM11/10/16
to vim/vim

This is just a guess (couldn't locate the relevant code), but for scenario 1 the issue may be that "keepalt" is used when the netrw browser is opened. Since there is no alternate buffer initially (when vim is opened to the empty buffer) and since netrw_altfile = 1 causes "keepalt" to be used when opening file 1 and then file 2, the non-existent alternate buffer is "keepalt"ed all the way through the sequence of operations.

If the above guess is correct, perhaps a solution would be to not use "keepalt" to open the netrw browser when netrw_altfile is 1.

Martin Vuille

unread,
Nov 22, 2016, 11:07:36 AM11/22/16
to vim/vim

@cecamp Any thoughts on this issue?
I'm willing to try to diagnose it further, just need some general guidance

Charles E Campbell

unread,
Nov 22, 2016, 12:40:49 PM11/22/16
to vim...@googlegroups.com
Martin Vuille wrote:
>
> @cecamp <https://github.com/cecamp> Any thoughts on this issue?
> I'm willing to try to diagnose it further, just need some general guidance
>
>
Hello:

My home computer is having problems, so I'm trying to get it working
properly again.

Presumably something needs a "keepalt" that currently doesn't have it.
Tracking that sort of thing down can be tedious. I'm hoping to try
Christian Brabandt's "breakpoint expr" patch; it doesn't appear to have
made it in vim v8 and use it to track down where @# changes.

Regards,
Chip Campbell

lacygoill

unread,
Aug 27, 2021, 12:37:43 AM8/27/21
to vim/vim, Subscribed

Scenario 1

I think this patch would fix the issue:

diff --git a/autoload/netrw.vim b/autoload/netrw.vim
index d095f6d..04aef12 100644
--- a/autoload/netrw.vim
+++ b/autoload/netrw.vim
@@ -4279,7 +4279,7 @@ fun! s:NetrwGetBuffer(islocal,dirname)
     exe "sil! NetrwKeepj noswapfile keepalt b ".bufnum
    else
 "    call Decho("  getline(2)<".getline(2).'> does not match "Netrw Directory Listing" : using b '.bufnum,'~'.expand("<slnum>"))
-    exe "sil! NetrwKeepj noswapfile keepalt b ".bufnum
+    exe "sil! NetrwKeepj noswapfile b ".bufnum
    endif
 "   call Decho("  line($)=".line("$"),'~'.expand("<slnum>"))
    if bufname("%") == '.'
@@ -11883,7 +11883,7 @@ fun! s:NetrwEnew(...)
   " COMBAK: this causes a problem, see P43
 "  setl nobl
   let netrw_keepdiff= &l:diff
-  noswapfile NetrwKeepj keepalt enew!
+  noswapfile NetrwKeepj enew!
   let &l:diff= netrw_keepdiff
 "  call Decho("bufnr($)=".bufnr("$")."<".bufname(bufnr("$"))."> winnr($)=".winnr("$"),'~'.expand("<slnum>"))
   NetrwKeepj call s:NetrwOptionsSave("w:")

Scenario 2

I'm not sure this behavior is guaranteed by the current documentation.


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.

Reply all
Reply to author
Forward
0 new messages