Skip to content

Commit 8a8fa09

Browse files
committed
Switch buffer if file is already opened instead of always call edit. This fix the problem where the cursor would always return at the beginning of the file.
1 parent 8ac2f79 commit 8a8fa09

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

plugin/fswitch.vim

100644100755
+5-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,11 @@ function! FSwitch(filename, precmd)
315315
if strlen(a:precmd) != 0
316316
execute a:precmd
317317
endif
318-
execute 'edit ' . fnameescape(newpath)
318+
if bufexists(newpath)
319+
execute 'buffer ' . fnameescape(newpath)
320+
else
321+
execute 'edit ' . fnameescape(newpath)
322+
endif
319323
else
320324
echoerr "Alternate has evaluated to nothing. See :h fswitch-empty for more info."
321325
endif

0 commit comments

Comments
 (0)