From 5ac14b3d3d3c9da65b58185b784b6b8f15ed5e0c Mon Sep 17 00:00:00 2001 From: Cj-bc Date: Fri, 1 Feb 2019 03:00:42 +0900 Subject: [PATCH 1/2] Change: gettags now always return json-contained list If no tags are found in `a:ags_string`, return list which only contains `{'name':''}` JSON so that we can use 'fix_tags' to correct the tag. This fixes the bug that updating post without tags failed. --- autoload/qiita.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/qiita.vim b/autoload/qiita.vim index 491c850..039d3a1 100644 --- a/autoload/qiita.vim +++ b/autoload/qiita.vim @@ -263,7 +263,7 @@ endfunction function! s:gettags(tags_string) if len(a:tags_string) == 0 - return [] + return [{'name':''}] endif let tags_list = split(a:tags_string, '\s\+') From 22d032911a5d40149350aa549dc422813edebc33 Mon Sep 17 00:00:00 2001 From: Cj-bc Date: Fri, 1 Feb 2019 03:07:09 +0900 Subject: [PATCH 2/2] Change: use 'fix_tags' in writing_item when it post new post Because of previous commit (`5ac14b3`), we don't need those codes as `gettgas` and `fix_tags` works the same. --- autoload/qiita.vim | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/autoload/qiita.vim b/autoload/qiita.vim index 039d3a1..35f0548 100644 --- a/autoload/qiita.vim +++ b/autoload/qiita.vim @@ -299,20 +299,12 @@ function! s:write_item(api, id, title, tags, content) endtry else redraw | echon 'Posting item... ' - if len(a:tags) == 0 - if len(&ft) == 0 - let l:tags = [{'name': 'text'}] - else - let l:tags = [{'name': &ft}] - endif - else - let l:tags = a:tags - endif + call s:fix_tags(a:tags) try let item = a:api.post_item({ \ 'title': a:title, \ 'body': a:content, - \ 'tags': l:tags, + \ 'tags': a:tags, \ 'private': v:false, \}) catch