Browse Source

Add additional test

Yegappan Lakshmanan 4 years ago
parent
commit
3a41546b2c
2 changed files with 28 additions and 9 deletions
  1. 9 9
      plugin/mru.vim
  2. 19 0
      test/unit_tests.vim

+ 9 - 9
plugin/mru.vim

@@ -313,18 +313,18 @@ func! s:MRU_Open_File_In_Tab(fname, esc_fname) abort
 	endwhile
 
 	if tabnum != -1
-	    " Goto the tab containing the file
-	    exe 'tabnext ' . i
+	  " Goto the tab containing the file
+	  exe 'tabnext ' . i
 	else
-        if (winnr("$") == 1) && (bufname("") == "") && !&modified
+	  if (winnr("$") == 1) && (@% == '') && !&modified
 	    " Reuse the current tab if it contains a single new unmodified
 	    " file.
-            exe 'e ' . a:esc_fname
-        else
-            " Open a new tab as the last tab page
-            tablast
-            exe 'tabnew ' . a:esc_fname
-        endif
+	    exe 'e ' . a:esc_fname
+	  else
+	    " Open a new tab as the last tab page
+	    tablast
+	    exe 'tabnew ' . a:esc_fname
+	  endif
 	endif
     endif
 

+ 19 - 0
test/unit_tests.vim

@@ -1113,6 +1113,25 @@ func Test_38()
   tabonly
 endfunc
 
+" ==========================================================================
+" Test39
+" Pressing 'd' in the MRU window should delete the file under the cursor
+" from the MRU list
+" ==========================================================================
+func Test39()
+  edit file2.txt
+  MRU
+  call search('file2.txt')
+  normal d
+  close
+  let l = readfile(g:MRU_File)
+  if match(l, 'file2.txt') == -1
+    call LogResult(test_name, 'pass')
+  else
+    call LogResult(test_name, 'FAIL')
+  endif
+endfunc
+
 " ==========================================================================
 
 " Create the files used by the tests