Skip to content

Commit

Permalink
fix: use the same logic for the DogeCreateDocStandard command in the …
Browse files Browse the repository at this point in the history
…test itself
  • Loading branch information
kkoomen committed Feb 17, 2021
1 parent e0f29d4 commit 2eafe9b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion autoload/doge/pattern.vim
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ function! doge#pattern#custom(name) abort
call add(l:doc, ' \ },')
call add(l:doc, ' \]')
call add(l:doc, 'endif')
call execute(':1,$d')
call setreg('"', l:doc)
1
call execute("normal! \"\"PGdd", 'silent!')
endfunction

let &cpoptions = s:save_cpo
unlet s:save_cpo
44 changes: 30 additions & 14 deletions test/commands/create-doc-standard.vader
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,22 @@ Execute (Create a new doc standard based on phpdoc, setup dummy pattern and exec
DogeCreateDocStandard phpdoc

Then (Expect a file to be created with specific content):
let b:path = '/after/ftplugin/php.vim'
if !has('nvim')
let b:path = '~/.vim' . b:path
elseif exists('*stdpath')
let b:path = '~/.config/nvim' . b:path
else
let b:path = getcwd() . b:path
let b:path = ''
for b:p in ['~/.vim', '~/vimfiles']
let b:p = expand(b:p)
if match(&runtimepath, b:p) >= 0
let b:path = b:p
break
endif
endfor
if empty(b:path)
if exists('*stdpath')
let b:path = stdpath('config')
else
let b:path = getcwd()
endif
endif
let b:path .= '/after/ftplugin/php.vim'
AssertEqual expand(b:path), expand('%:p')

let b:content = join([
Expand Down Expand Up @@ -104,14 +112,22 @@ Execute (Create a new doc standard for an unsupported filetype, setup dummy patt
DogeCreateDocStandard foo

Then (Expect a file to be created with specific content):
let b:path = '/after/ftplugin/foo.vim'
if !has('nvim')
let b:path = '~/.vim' . b:path
elseif exists('*stdpath')
let b:path = '~/.config/nvim' . b:path
else
let b:path = getcwd() . b:path
let b:path = ''
for b:p in ['~/.vim', '~/vimfiles']
let b:p = expand(b:p)
if match(&runtimepath, b:p) >= 0
let b:path = b:p
break
endif
endfor
if empty(b:path)
if exists('*stdpath')
let b:path = stdpath('config')
else
let b:path = getcwd()
endif
endif
let b:path .= '/after/ftplugin/foo.vim'
AssertEqual expand(b:path), expand('%:p')

let b:content = join([
Expand Down

0 comments on commit 2eafe9b

Please sign in to comment.