Quellcode durchsuchen

Use a:pat instead of pat and add a cmd script to run unit tests on MS-Windows

Yegappan Lakshmanan vor 4 Jahren
Ursprung
Commit
73f80b2d82
3 geänderte Dateien mit 24 neuen und 5 gelöschten Zeilen
  1. 4 2
      plugin/mru.vim
  2. 16 0
      test/mru_unittest.cmd
  3. 4 3
      test/unit_tests.vim

+ 4 - 2
plugin/mru.vim

@@ -317,6 +317,8 @@ func! s:MRU_Open_File_In_Tab(fname, esc_fname) abort
 	    exe 'tabnext ' . i
 	else
         if (winnr("$") == 1) && (bufname("") == "") && !&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
@@ -640,10 +642,10 @@ func! s:MRU_Open_Window(pat, splitdir) abort
     else
         " Display only the entries matching the specified pattern
 	" First try using it as a literal pattern
-	let m = filter(copy(s:MRU_files), 'stridx(v:val, pat) != -1')
+	let m = filter(copy(s:MRU_files), 'stridx(v:val, a:pat) != -1')
 	if len(m) == 0
 	    " No match. Try using it as a regular expression
-	    let m = filter(copy(s:MRU_files), 'v:val =~# pat')
+	    let m = filter(copy(s:MRU_files), 'v:val =~# a:pat')
 	endif
     endif
 

+ 16 - 0
test/mru_unittest.cmd

@@ -0,0 +1,16 @@
+@echo off
+
+REM Script to run the unit-tests for the MRU Vim plugin on MS-Windows
+
+SETLOCAL 
+SET VIM="C:\Program Files (x86)\vim\vim82\vim.exe"
+SET VIM_CMD=%VIM% -N -u NONE -U NONE -i NONE
+
+%VIM_CMD% -S unit_tests.vim
+
+echo MRU unit test results
+type results.txt
+
+findstr /I FAIL results.txt > nul 2>&1
+if %ERRORLEVEL% EQU 0 echo ERROR: Some test failed.
+if %ERRORLEVEL% NEQ 0 echo SUCCESS: All the tests passed.

+ 4 - 3
test/unit_tests.vim

@@ -285,9 +285,10 @@ func Test_11()
   let test_name = 'test11'
   enew | only
 
-  tabnew
-  tabnew
-  tabnew
+  edit a1.txt
+  tabnew a2.txt
+  tabnew a3.txt
+  tabnew a4.txt
   tabfirst
   MRU
   call search('file3.txt')