aboutsummaryrefslogtreecommitdiff
path: root/autoload/prettier
diff options
context:
space:
mode:
authormitermayer <mitermayer.reis@gmail.com>2018-06-22 11:35:39 -0700
committermitermayer <mitermayer.reis@gmail.com>2019-08-25 21:13:01 -0700
commit98b6fb2a77670bfd3f8fce627f5e5c1935cb82ad (patch)
tree647644a60215212aaf71579001e1f8d4286502ca /autoload/prettier
parent1d045d3c2ea7466d523b1bad64992d081d6de088 (diff)
downloadvim-prettier-98b6fb2a77670bfd3f8fce627f5e5c1935cb82ad.tar.xz
Fixing job runner lock flag
- Making sure we do not try to format a file again until execution is finally finished
Diffstat (limited to 'autoload/prettier')
-rw-r--r--autoload/prettier/job/async/neovim.vim4
-rw-r--r--autoload/prettier/job/async/vim.vim4
2 files changed, 5 insertions, 3 deletions
diff --git a/autoload/prettier/job/async/neovim.vim b/autoload/prettier/job/async/neovim.vim
index ce3b349..1cffe5c 100644
--- a/autoload/prettier/job/async/neovim.vim
+++ b/autoload/prettier/job/async/neovim.vim
@@ -42,7 +42,6 @@ endfunction
"
" note that somehow we exectuing both async and sync on nvim when using the autoformat
function! s:onExit(status, info, out, err) abort
- let s:prettier_job_running = 0
let l:currentBufferNumber = bufnr('%')
let l:isInsideAnotherBuffer = a:info.buf_nr != l:currentBufferNumber ? 1 : 0
let l:last = a:out[len(a:out) - 1]
@@ -51,6 +50,7 @@ function! s:onExit(status, info, out, err) abort
" parsing errors
if a:status != 0
call prettier#job#runner#onError(a:err)
+ let s:prettier_job_running = 0
return
endif
@@ -93,4 +93,6 @@ function! s:onExit(status, info, out, err) abort
call nvim_buf_set_lines(a:info.buf_nr, a:info.start, a:info.end, 0, l:out)
write
endif
+
+ let s:prettier_job_running = 0
endfunction
diff --git a/autoload/prettier/job/async/vim.vim b/autoload/prettier/job/async/vim.vim
index d84d406..ab0fbef 100644
--- a/autoload/prettier/job/async/vim.vim
+++ b/autoload/prettier/job/async/vim.vim
@@ -23,8 +23,6 @@ function! s:onError(msg) abort
endfunction
function! s:onClose(channel, startSelection, endSelection, bufferName) abort
- let s:prettier_job_running = 0
-
let l:out = []
let l:currentBufferName = bufname('%')
let l:isInsideAnotherBuffer = a:bufferName != l:currentBufferName ? 1 : 0
@@ -38,6 +36,7 @@ function! s:onClose(channel, startSelection, endSelection, bufferName) abort
" nothing to update
if (prettier#utils#buffer#willUpdatedLinesChangeBuffer(l:out, a:startSelection, a:endSelection) == 0)
+ let s:prettier_job_running = 0
return
endif
@@ -63,4 +62,5 @@ function! s:onClose(channel, startSelection, endSelection, bufferName) abort
else
call prettier#utils#buffer#replaceAndSave(l:out, a:startSelection, a:endSelection)
endif
+ let s:prettier_job_running = 0
endfunction