This change ensures the syntax is properly changed when running multiple tests by removing the previously created temporary wiki and then creating a new one.
		
			
				
	
	
		
			49 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
Before (Define functions):
 | 
						|
  " change the syntax using a temporary wiki
 | 
						|
  function! SetSyntax(vw_syn)
 | 
						|
    if a:vw_syn ==# 'default'
 | 
						|
      let ext = 'wiki'
 | 
						|
    elseif a:vw_syn ==# 'markdown'
 | 
						|
      let ext = 'md'
 | 
						|
    elseif a:vw_syn ==# 'media'
 | 
						|
      let ext = 'mw'
 | 
						|
    else
 | 
						|
      Log 'ERROR: Invalid syntax "' . a:vw_syn . '" in SetSyntax()'
 | 
						|
      Log 'NOTE: function only accepts "media" for setting mediawiki syntax'
 | 
						|
      return
 | 
						|
    endif
 | 
						|
    let path = expand('%:p:h')
 | 
						|
    let new_temp_wiki_settings = {'path': path,
 | 
						|
          \ 'ext': ext,
 | 
						|
          \ 'syntax': a:vw_syn,
 | 
						|
          \ }
 | 
						|
 | 
						|
    " Remove any temporary wikis each time this function is called.
 | 
						|
    " This is necessary to ensure syntax is properly set when running multiple tests
 | 
						|
    " NOTE: this assumes there are 3 defined wikis in the vimrc. The last wiki
 | 
						|
    " contains default settings for temporary wikis (so there are always
 | 
						|
    " num wikis in vimrc + 1)
 | 
						|
    let num_wikis = len(g:vimwiki_wikilocal_vars)
 | 
						|
    while  num_wikis > 4
 | 
						|
      call remove(g:vimwiki_wikilocal_vars, num_wikis - 1)
 | 
						|
      let num_wikis = num_wikis - 1
 | 
						|
    endwhile
 | 
						|
 | 
						|
    " add the new wiki
 | 
						|
    call vimwiki#vars#add_temporary_wiki(new_temp_wiki_settings)
 | 
						|
    call vimwiki#vars#set_bufferlocal('wiki_nr', 3)
 | 
						|
 | 
						|
    " verify syntax was set correctly
 | 
						|
    Assert vimwiki#vars#get_wikilocal('syntax') ==# a:vw_syn, 'ERROR: Vimwiki syntax not set correctly.'
 | 
						|
  endfunction
 | 
						|
 | 
						|
  " reload plugin to change settings
 | 
						|
  function! ReloadVimwiki()
 | 
						|
    " clear mappings so plugin can be reloaded
 | 
						|
    " this is needed if running manually multiple times
 | 
						|
    nmapclear
 | 
						|
 | 
						|
    unlet g:loaded_vimwiki
 | 
						|
    source plugin/vimwiki.vim
 | 
						|
  endfunction
 |