Hi Bram and list,
How to reproduce:
- Create file for test.
$ touch hh.txt
- Open file on other instance Vim.
$ vim -Nu NONE hh.txt
- Run Vim
$ vim -Nu NONE hh.txt
- type hh.txt to current buffer
ihh.txt<Esc>
- Open a new tab page and edit the file name under the cursor. (:h CTRL-W_gf)
<C-W>gf
- Displayed the following dialog. and you type `q`.
Swap file ".hh.txt.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:
Expected behavior:
- Tab page will not be opened.
Actual behavior:
- Tab page is opened. I think this is a waste.
I attached a patch.
NOTE: This patch was written by Norio Takagi. (I only added a test)
Please include this.
--
Best regards,
Hirohito Higashi (a.k.a. h_east)
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim
index d2e4272..b7f41a7 100644
--- a/src/testdir/test_window_cmd.vim
+++ b/src/testdir/test_window_cmd.vim
@@ -34,4 +34,37 @@ func Test_window_cmd_cmdwin_with_vsp()
set ls&vim
endfunc
+function Test_window_cmd_wincmd_gf()
+ let fname = 'test_gf.txt'
+ let swp_fname = '.' . fname . '.swp'
+ call writefile([], fname)
+ call writefile([], swp_fname)
+ function s:swap_exists()
+ let v:swapchoice = s:swap_choice
+ endfunc
+ augroup test_window_cmd_wincmd_gf
+ autocmd!
+ exec "autocmd SwapExists " . fname . " call s:swap_exists()"
+ augroup END
+
+ call setline(1, fname)
+ " (E)dit anyway
+ let s:swap_choice = 'e'
+ wincmd gf
+ call assert_equal(2, tabpagenr())
+ call assert_equal(fname, bufname("%"))
+ quit!
+
+ " (Q)uit
+ let s:swap_choice = 'q'
+ wincmd gf
+ call assert_equal(1, tabpagenr())
+ call assert_notequal(fname, bufname("%"))
+ new | only!
+
+ call delete(fname)
+ call delete(swp_fname)
+ augroup! test_window_cmd_wincmd_gf
+endfunc
+
" vim: sw=2 et
diff --git a/src/window.c b/src/window.c
index 2dc2554..5420c19 100644
--- a/src/window.c
+++ b/src/window.c
@@ -475,6 +475,8 @@ wingotofile:
ptr = grab_file_name(Prenum1, &lnum);
if (ptr != NULL)
{
+ tabpage_T *oldtab = curtab;
+ win_T *oldwin = curwin;
# ifdef FEAT_GUI
need_mouse_correct = TRUE;
# endif
@@ -482,9 +484,13 @@ wingotofile:
if (win_split(0, 0) == OK)
{
RESET_BINDING(curwin);
- (void)do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL,
- ECMD_HIDE, NULL);
- if (nchar == 'F' && lnum >= 0)
+ if (do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL,
+ ECMD_HIDE, NULL) == FAIL)
+ {
+ win_close(curwin, FALSE);
+ goto_tabpage_win(oldtab, oldwin);
+ }
+ else if (nchar == 'F' && lnum >= 0)
{
curwin->w_cursor.lnum = lnum;
check_cursor_lnum();