From da8b5c52353444e74958fb034425c7ea04f1b781 Mon Sep 17 00:00:00 2001 From: Kim K Date: Thu, 5 Mar 2020 22:16:51 +0800 Subject: [PATCH] fix(doge#buffer#get_supported_doc_standards): Order list based on how it should be defined --- autoload/doge/buffer.vim | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/autoload/doge/buffer.vim b/autoload/doge/buffer.vim index 25337ccd..ef792e4c 100644 --- a/autoload/doge/buffer.vim +++ b/autoload/doge/buffer.vim @@ -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 ""