Skip to content

Commit 96c82ec

Browse files
committed
normalize name and description
1 parent 4416a53 commit 96c82ec

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

autoload/gist.vim

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ function! s:format_gist(gist)
100100
else
101101
let code = ""
102102
endif
103-
return printf("gist: %s %s %s%s", a:gist.id, name, type(a:gist.description)==0 || a:gist.description==""?"":'('.a:gist.description.')', code)
103+
let desc = type(a:gist.description)==0 || a:gist.description == "" ? "" : '('.a:gist.description.')'
104+
let name = substitute(name, '[\r\n\t]', ' ', 'g')
105+
let name = substitute(name, ' ', ' ', 'g')
106+
let desc = substitute(desc, '[\r\n\t]', ' ', 'g')
107+
let desc = substitute(desc, ' ', ' ', 'g')
108+
return printf("gist: %s %s %s%s", a:gist.id, name, desc, code)
104109
endfunction
105110

106111
" Note: A colon in the file name has side effects on Windows due to NTFS Alternate Data Streams; avoid it.
@@ -446,7 +451,7 @@ function! s:get_current_filename(no)
446451
return filename
447452
endfunction
448453

449-
function s:update_GistID(id)
454+
function! s:update_GistID(id)
450455
let view = winsaveview()
451456
normal! gg
452457
if search('\<GistID\>:\s*$')

0 commit comments

Comments
 (0)