From 6d2acb7635930fb04193a7393e67029dd2a47e33 Mon Sep 17 00:00:00 2001 From: Christian Hubinger Date: Tue, 14 Mar 2017 15:15:02 +0100 Subject: [PATCH] fix: linter discards unsaved changes The content of the current buffer is written to the tempfile instead of copying the file. So unsaved changes will no longer be discarded silently. --- plugin/defaults.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin/defaults.vim b/plugin/defaults.vim index 0e6f53a..4085f02 100644 --- a/plugin/defaults.vim +++ b/plugin/defaults.vim @@ -186,8 +186,9 @@ if !exists('g:formatdef_eslint_local') " This formatter uses a temporary file as ESLint has not option to print " the formatted source to stdout without modifieing the file. let l:eslint_js_tmp_file = fnameescape(tempname().".js") - return "rm -f ".l:eslint_js_tmp_file."; cat ".l:path." > ".l:eslint_js_tmp_file.";" - \ .l:prog." -c ".l:cfg." --fix ".l:eslint_js_tmp_file." 1> /dev/null; exit_code=$? + let content = getline('1', '$') + call writefile(content, l:eslint_js_tmp_file) + return l:prog." -c ".l:cfg." --fix ".l:eslint_js_tmp_file." 1> /dev/null; exit_code=$? \ cat ".l:eslint_js_tmp_file."; rm -f ".l:eslint_js_tmp_file."; exit $exit_code" endfunction let g:formatdef_eslint_local = "g:BuildESLintLocalCmd()"