Browse Source

Fix CI failure and add additional test

Yegappan Lakshmanan 4 years ago
parent
commit
be282f0aaa
2 changed files with 55 additions and 1 deletions
  1. 1 1
      plugin/mru.vim
  2. 54 0
      test/unit_tests.vim

+ 1 - 1
plugin/mru.vim

@@ -599,7 +599,7 @@ func! s:MRU_Open_Window(pat, splitdir, winsz) abort
       let bufnum = bufnr(bname)
       if bufnum == -1
 	if split_window
-	  let cmd = 'botright split edit ' . bname
+	  let cmd = 'botright split ' . bname
 	else
 	  let cmd = 'edit ' . bname
 	endif

+ 54 - 0
test/unit_tests.vim

@@ -1665,6 +1665,60 @@ func Test_56()
   call LogResult(test_name, 'pass')
 endfunc
 
+" ==========================================================================
+" Test57
+" When the MRU window is closed, the MRU buffer should be unloaded.
+" If 'MRU_Use_Current_Window' is set, then the MRU buffer should be wiped out.
+" ==========================================================================
+func Test_57()
+  let test_name = 'test57'
+  MRU
+  let mrubnum = bufnr()
+  close
+  if bufloaded(mrubnum)
+    call LogResult(test_name, 'FAIL (1)')
+    return
+  endif
+  let g:MRU_Use_Current_Window = 1
+  new
+  edit Xfile
+  MRU
+  let mrubnum = bufnr()
+  edit #
+  if bufexists(mrubnum) || @% != 'Xfile'
+    call LogResult(test_name, 'FAIL (2)')
+    return
+  endif
+  let g:MRU_Use_Current_Window = 0
+  %bw!
+  call LogResult(test_name, 'pass')
+endfunc
+
+" ==========================================================================
+" Test58
+" When the MRU window is toggled with MRU_Use_Current_Window set to 1, the
+" previous buffer should be loaded.
+" ==========================================================================
+func Test_58()
+  let test_name = 'test58'
+  let g:MRU_Use_Current_Window = 1
+  new
+  edit Xfile
+  MRUToggle
+  if @% != MRU_buffer_name || winnr('$') != 2
+    call LogResult(test_name, 'FAIL (1)')
+    return
+  endif
+  MRUToggle
+  if @% != 'Xfile' || winnr('$') != 2
+    call LogResult(test_name, 'FAIL (2)')
+    return
+  endif
+  let g:MRU_Use_Current_Window = 0
+  %bw!
+  call LogResult(test_name, 'pass')
+endfunc
+
 " ==========================================================================
 
 " Create the files used by the tests