@@ -534,6 +534,15 @@ function! s:GistListAction(mode) abort
534
534
endif
535
535
endfunction
536
536
537
+ func s: fix_eol (content) abort
538
+ let s = a: content
539
+ let lastchar= char2nr (s [-1 :])
540
+ if lastchar != 10
541
+ let s .= " \n "
542
+ endif
543
+ return s
544
+ endfunc
545
+
537
546
function ! s: GistUpdate (content, gistid, gistnm, desc) abort
538
547
let gist = { ' id' : a: gistid , ' files' : {}, ' description' : ' ' ,' public' : function (' webapi#json#true' ) }
539
548
if exists (' b:gist' )
@@ -569,7 +578,8 @@ function! s:GistUpdate(content, gistid, gistnm, desc) abort
569
578
endif
570
579
endif
571
580
572
- let gist.files [filename] = { ' content' : a: content , ' filename' : filename }
581
+ let content = s: fix_eol (a: content )
582
+ let gist.files [filename] = { ' content' : content, ' filename' : filename }
573
583
574
584
redraw | echon ' Updating gist... '
575
585
let res = webapi#http#post (g: gist_api_url .' gists/' . a: gistid ,
@@ -663,7 +673,7 @@ function! s:GistPost(content, private, desc, anonymous) abort
663
673
if a: desc !=# ' ' | let gist[' description' ] = a: desc | endif
664
674
if a: private | let gist[' public' ] = function (' webapi#json#false' ) | endif
665
675
let filename = s: get_current_filename (1 )
666
- let gist.files [filename] = { ' content' : a: content , ' filename' : filename }
676
+ let gist.files [filename] = { ' content' : s: fix_eol ( a: content) , ' filename' : filename }
667
677
668
678
let header = {' Content-Type' : ' application/json' }
669
679
if ! a: anonymous
@@ -714,7 +724,7 @@ function! s:GistPostBuffers(private, desc, anonymous) abort
714
724
endif
715
725
echo ' Creating gist content' .index .' ... '
716
726
silent ! exec ' buffer!' bufnr
717
- let content = join (getline (1 , line (' $' )), " \n " )
727
+ let content = s: fix_eol ( join (getline (1 , line (' $' )), " \n " ) )
718
728
let filename = s: get_current_filename (index )
719
729
let gist.files [filename] = { ' content' : content, ' filename' : filename }
720
730
let index = index + 1
0 commit comments