robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3 4local describe , it , before_each , after_each =t . describe , t . it , t . before_each , t . after_each 5local clear =n . clear 6local command =n . command 7local get_pathsep =n . get_pathsep 8local eq =t . eq 9local fn =n . fn 10local rmdir =n . rmdir 11local mkdir =t . mkdir 12 13local file_prefix ='Xtest-functional-ex_cmds-mkview_spec' 14 15describe ( ':mkview' , function () 16local tmp_file_base =file_prefix .. '-tmpfile' 17local local_dir =file_prefix .. '.d' 18local view_dir =file_prefix .. '.view.d' 19 20before_each ( function () 21clear () 22mkdir ( view_dir ) 23mkdir ( local_dir ) 24end ) 25 26after_each ( function () 27-- Remove any views created in the view directory 28rmdir ( view_dir ) 29rmdir ( local_dir ) 30end ) 31 32it ( 'viewoption curdir restores local current directory' , function () 33local cwd_dir =fn . getcwd () 34local set_view_dir_command ='set viewdir=' .. cwd_dir .. get_pathsep () .. view_dir 35 36-- By default the local current directory should save 37command ( set_view_dir_command ) 38command ( 'edit ' .. tmp_file_base .. '1' ) 39command ( 'lcd ' .. local_dir ) 40command ( 'mkview' ) 41 42-- Create a new instance of Nvim to remove the 'lcd' 43clear () 44 45-- Disable saving the local current directory for the second view 46command ( set_view_dir_command ) 47command ( 'set viewoptions-=curdir' ) 48command ( 'edit ' .. tmp_file_base .. '2' ) 49command ( 'lcd ' .. local_dir ) 50command ( 'mkview' ) 51 52-- Create a new instance of Nvim to test saved 'lcd' option 53clear () 54command ( set_view_dir_command ) 55 56-- Load the view without a saved local current directory 57command ( 'edit ' .. tmp_file_base .. '2' ) 58command ( 'loadview' ) 59-- The view's current directory should not have changed 60eq ( cwd_dir , fn . getcwd ()) 61-- Load the view with a saved local current directory 62command ( 'edit ' .. tmp_file_base .. '1' ) 63command ( 'loadview' ) 64-- The view's local directory should have been saved 65eq ( cwd_dir .. get_pathsep () .. local_dir , fn . getcwd ()) 66end ) 67end )