aboutsummaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorMitermayer Reis <mitermayer.reis@gmail.com>2018-06-18 13:38:57 -0700
committerGitHub <noreply@github.com>2018-06-18 13:38:57 -0700
commit827eb1e05ede6ba57e82156c83c6c218fabd19b8 (patch)
treeedd00033e4a0f4397b719a4c37da3d2f47049e22 /autoload
parent3f54aabb48199375876e86adf940cb58f9532095 (diff)
parent578561873cb4772baee2c6d0e7e3ab9cd60d2995 (diff)
downloadvim-prettier-827eb1e05ede6ba57e82156c83c6c218fabd19b8.tar.xz
Merge pull request #142 from SamHowie/master
Fix PrettierAsync ignored file contents mangling
Diffstat (limited to 'autoload')
-rw-r--r--autoload/prettier.vim8
1 files changed, 5 insertions, 3 deletions
diff --git a/autoload/prettier.vim b/autoload/prettier.vim
index f322545..7b20b25 100644
--- a/autoload/prettier.vim
+++ b/autoload/prettier.vim
@@ -169,6 +169,7 @@ function! s:Prettier_Exec_Async(cmd, startSelection, endSelection) abort
if s:prettier_job_running != 1
let s:prettier_job_running = 1
let l:job = job_start([&shell, &shellcmdflag, l:async_cmd], {
+ \ 'out_io': 'buffer',
\ 'err_cb': {channel, msg -> s:Prettier_Job_Error(msg)},
\ 'close_cb': {channel -> s:Prettier_Job_Close(channel, a:startSelection, a:endSelection, l:bufferName)}})
let l:stdin = job_getchannel(l:job)
@@ -182,13 +183,14 @@ function! s:Prettier_Job_Close(channel, startSelection, endSelection, bufferName
let l:currentBufferName = bufname('%')
let l:isInsideAnotherBuffer = a:bufferName != l:currentBufferName ? 1 : 0
- while ch_status(a:channel) ==# 'buffered'
- call add(l:out, ch_read(a:channel))
- endwhile
+ let l:buff = ch_getbufnr(a:channel, 'out')
+ let l:out = getbufline(l:buff, 2, '$')
+ execute 'bd!' . l:buff
" nothing to update
if (s:Has_Content_Changed(l:out, a:startSelection, a:endSelection) == 0)
let s:prettier_job_running = 0
+ redraw!
return
endif