Skip to content

Commit

Permalink
fix(doge#buffer#get_supported_doc_standards): Order list based on how…
Browse files Browse the repository at this point in the history
… it should be defined
  • Loading branch information
kkoomen committed Mar 5, 2020
1 parent 94d4f1a commit da8b5c5
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions autoload/doge/buffer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,21 @@ endfunction
" 'defaults': A list of supported doc standards that should be allowed.
" Returns a list of accepted doc standards.
function! doge#buffer#get_supported_doc_standards(defaults) abort
return get(g:, 'doge_test_env', 0)
\ ? a:defaults
\ : uniq(sort(extend(get(b:, 'doge_supported_doc_standards', []), a:defaults)))
if get(g:, 'doge_test_env', 0)
return a:defaults
endif

" We sort them so that we can use uniq() on it.
let l:docs = uniq(sort(extend(get(b:, 'doge_supported_doc_standards', []), a:defaults)))

" After sorted it, we will remove the defaults and prepend the defaults so
" that we can reset the order as we defined it in the ftplugin/{ft}.vim.
for l:default in a:defaults
call remove(l:docs, index(l:docs, l:default))
endfor

" Prepend the defaults to the filtered docs list.
return extend(a:defaults, l:docs)
endfunction

""
Expand Down

0 comments on commit da8b5c5

Please sign in to comment.