From 62fdd10233a0ad8da88e02a4d7e3c476da57859c Mon Sep 17 00:00:00 2001 From: Sam Howie Date: Thu, 24 May 2018 20:59:24 -0700 Subject: Fix PrettierAsync segmentation fault --- autoload/prettier.vim | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'autoload') diff --git a/autoload/prettier.vim b/autoload/prettier.vim index 4b5a4e9..f00426e 100644 --- a/autoload/prettier.vim +++ b/autoload/prettier.vim @@ -168,14 +168,13 @@ function! s:Prettier_Exec_Async(cmd, startSelection, endSelection) abort if s:prettier_job_running != 1 let s:prettier_job_running = 1 - call job_start([&shell, &shellcmdflag, l:async_cmd], { - \ 'in_io': 'buffer', - \ 'in_top': a:startSelection, - \ 'in_bot': a:endSelection, - \ 'in_name': l:bufferName, + let l:job = job_start([&shell, &shellcmdflag, l:async_cmd], { \ 'err_cb': {channel, msg -> s:Prettier_Job_Error(msg)}, \ 'close_cb': {channel -> s:Prettier_Job_Close(channel, a:startSelection, a:endSelection, l:bufferName)}}) - endif + let l:stdin = job_getchannel(l:job) + call ch_sendraw(l:stdin, join(getbufline(bufnr(l:bufferName), a:startSelection,a:endSelection), "\n")) + call ch_close_in(l:stdin) + endif endfunction function! s:Prettier_Job_Close(channel, startSelection, endSelection, bufferName) abort @@ -278,10 +277,14 @@ function! s:Apply_Prettier_Format(lines, startSelection, endSelection) abort endif " delete all lines on the current buffer - silent! execute len(l:newBuffer) . ',' . line('$') . 'delete _' + silent! execute '%delete _' " replace all lines from the current buffer with output from prettier - call setline(1, l:newBuffer) + let l:idx = 0 + for l:line in l:newBuffer + silent! call append(l:idx, l:line) + let l:idx += 1 + endfor " Restore view call winrestview(l:winview) -- cgit v1.3 From 13d6948ca17540a2c480812f7d39d1b5ba102a38 Mon Sep 17 00:00:00 2001 From: Sam Howie Date: Fri, 25 May 2018 11:37:04 -0700 Subject: Remove trailing empty line introduced by append --- autoload/prettier.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'autoload') diff --git a/autoload/prettier.vim b/autoload/prettier.vim index f00426e..dcd9926 100644 --- a/autoload/prettier.vim +++ b/autoload/prettier.vim @@ -285,7 +285,10 @@ function! s:Apply_Prettier_Format(lines, startSelection, endSelection) abort silent! call append(l:idx, l:line) let l:idx += 1 endfor - + + " delete trailing newline introduced by the above append procedure + silent! execute '$delete _' + " Restore view call winrestview(l:winview) endfunction -- cgit v1.3 From 8f22354d9138b76646958bcc257111a4a5f23d98 Mon Sep 17 00:00:00 2001 From: mitermayer Date: Fri, 25 May 2018 13:07:18 -0700 Subject: 0.2.7 patch release --- autoload/prettier.vim | 2 +- doc/prettier.txt | 2 +- package.json | 2 +- plugin/prettier.vim | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'autoload') diff --git a/autoload/prettier.vim b/autoload/prettier.vim index dcd9926..f322545 100644 --- a/autoload/prettier.vim +++ b/autoload/prettier.vim @@ -5,7 +5,7 @@ " Name Of File: prettier.vim " Description: A vim plugin wrapper for prettier, pre-configured with custom default prettier settings. " Maintainer: Mitermayer Reis -" Version: 0.2.6 +" Version: 0.2.7 " Usage: Use :help vim-prettier-usage, or visit https://github.com/prettier/vim-prettier " "========================================================================================================== diff --git a/doc/prettier.txt b/doc/prettier.txt index 99b8d70..59078b8 100644 --- a/doc/prettier.txt +++ b/doc/prettier.txt @@ -8,7 +8,7 @@ Author: Mitermayer Reis WebSite: https://prettier.io/ Repository: https://github.com/prettier/vim-prettier License: MIT style license -Version: 0.2.6 +Version: 0.2.7 ============================================================================== CONTENTS *vim-prettier-contents* diff --git a/package.json b/package.json index 78811d6..901597e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vim-prettier", "author": "Mitermayer Reis ", - "version": "0.2.6", + "version": "0.2.7", "description": "Vim plugin for prettier", "license": "MIT", "repository": { diff --git a/plugin/prettier.vim b/plugin/prettier.vim index da008fe..b7f2855 100644 --- a/plugin/prettier.vim +++ b/plugin/prettier.vim @@ -5,7 +5,7 @@ " Name Of File: prettier.vim " Description: A vim plugin wrapper for prettier, pre-configured with custom default prettier settings. " Maintainer: Mitermayer Reis -" Version: 0.2.6 +" Version: 0.2.7 " Usage: Use :help vim-prettier-usage, or visit https://github.com/prettier/vim-prettier " "========================================================================================================== @@ -79,7 +79,7 @@ command! -nargs=? -range=% Prettier call prettier#Prettier(g:prettier#exec_cmd_a command! -nargs=? -range=% PrettierAsync call prettier#Prettier(1, , ) " prints vim-prettier version -command! -nargs=? -range=% PrettierVersion echom '0.2.6' +command! -nargs=? -range=% PrettierVersion echom '0.2.7' " call prettier cli command! -nargs=? -range=% PrettierCli call prettier#PrettierCli() -- cgit v1.3 From 8de915079f143729dad857273fb8fdd5753657ee Mon Sep 17 00:00:00 2001 From: Sam Howie Date: Fri, 15 Jun 2018 01:08:36 -0700 Subject: Fix PrettierAsync ignored file contents mangling --- autoload/prettier.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'autoload') diff --git a/autoload/prettier.vim b/autoload/prettier.vim index f322545..b94ea4a 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,9 +183,9 @@ 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) -- cgit v1.3 From 578561873cb4772baee2c6d0e7e3ab9cd60d2995 Mon Sep 17 00:00:00 2001 From: Sam Howie Date: Fri, 15 Jun 2018 01:09:36 -0700 Subject: Fix PrettierAsync unchanged buffer rendering issue --- autoload/prettier.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'autoload') diff --git a/autoload/prettier.vim b/autoload/prettier.vim index b94ea4a..7b20b25 100644 --- a/autoload/prettier.vim +++ b/autoload/prettier.vim @@ -190,6 +190,7 @@ function! s:Prettier_Job_Close(channel, startSelection, endSelection, bufferName " nothing to update if (s:Has_Content_Changed(l:out, a:startSelection, a:endSelection) == 0) let s:prettier_job_running = 0 + redraw! return endif -- cgit v1.3 From 8850ff2b1bc30752725b0d0f9f58be8e78e2b7e8 Mon Sep 17 00:00:00 2001 From: Oskar Date: Tue, 19 Jun 2018 17:49:52 +0200 Subject: Enable the default editorconfig support again --- autoload/prettier.vim | 1 - 1 file changed, 1 deletion(-) (limited to 'autoload') diff --git a/autoload/prettier.vim b/autoload/prettier.vim index 7b20b25..c703fba 100644 --- a/autoload/prettier.vim +++ b/autoload/prettier.vim @@ -326,7 +326,6 @@ function! s:Get_Prettier_Exec_Args(config) abort \ get(a:config, 'proseWrap', g:prettier#config#prose_wrap) . \ ' --stdin-filepath ' . \ simplify(expand('%:p')) . - \ ' --no-editorconfig '. \ ' --loglevel error '. \ ' --stdin ' return l:cmd -- cgit v1.3