diff src/testdir/test_swap.vim @ 21337:647897e6df9e v8.2.1219

patch 8.2.1219: symlink not followed if dirname ends in // Commit: https://github.com/vim/vim/commit/5966ea105ea86e52a734e04267956e11efffc92d Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jul 15 15:30:05 2020 +0200 patch 8.2.1219: symlink not followed if dirname ends in // Problem: Symlink not followed if dirname ends in //. Solution: Resolve symlink earlier. (Tom?? Janou?ek, closes https://github.com/vim/vim/issues/6454)
author Bram Moolenaar <Bram@vim.org>
date Wed, 15 Jul 2020 15:45:03 +0200
parents c087099e9163
children 08940efa6b4e
line wrap: on
line diff
--- a/src/testdir/test_swap.vim
+++ b/src/testdir/test_swap.vim
@@ -377,4 +377,34 @@ func Test_swap_prompt_splitwin()
   call delete('Xfile1')
 endfunc
 
+func Test_swap_symlink()
+  if !has("unix")
+    return
+  endif
+
+  call writefile(['text'], 'Xtestfile')
+  silent !ln -s -f Xtestfile Xtestlink
+
+  set dir=.
+
+  " Test that swap file uses the name of the file when editing through a
+  " symbolic link (so that editing the file twice is detected)
+  edit Xtestlink
+  call assert_match('Xtestfile\.swp$', s:swapname())
+  bwipe!
+
+  call mkdir('Xswapdir')
+  exe 'set dir=' . getcwd() . '/Xswapdir//'
+
+  " Check that this also works when 'directory' ends with '//'
+  edit Xtestlink
+  call assert_match('Xtestfile\.swp$', s:swapname())
+  bwipe!
+
+  set dir&
+  call delete('Xtestfile')
+  call delete('Xtestlink')
+  call delete('Xswapdir', 'rf')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab