mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-31 15:15:32 +08:00
#2132 Move CreateTemporaryFileForJob calls into FormatCommand
This commit is contained in:
@@ -20,7 +20,7 @@ endfunction
|
||||
" %s -> with the current filename
|
||||
" %t -> with the name of an unused file in a temporary directory
|
||||
" %% -> with a literal %
|
||||
function! ale#command#FormatCommand(buffer, executable, command, pipe_file_if_needed) abort
|
||||
function! ale#command#FormatCommand(buffer, executable, command, pipe_file_if_needed, CreateTemporaryFileForJob) abort
|
||||
let l:temporary_file = ''
|
||||
let l:command = a:command
|
||||
|
||||
@@ -58,5 +58,7 @@ function! ale#command#FormatCommand(buffer, executable, command, pipe_file_if_ne
|
||||
let l:command = l:command . ' < ' . ale#Escape(l:temporary_file)
|
||||
endif
|
||||
|
||||
return [l:temporary_file, l:command]
|
||||
let l:file_created = a:CreateTemporaryFileForJob(a:buffer, l:temporary_file)
|
||||
|
||||
return [l:temporary_file, l:command, l:file_created]
|
||||
endfunction
|
||||
|
||||
@@ -512,14 +512,15 @@ function! s:RunJob(options) abort
|
||||
let l:read_buffer = a:options.read_buffer
|
||||
let l:info = g:ale_buffer_info[l:buffer]
|
||||
|
||||
let [l:temporary_file, l:command] = ale#command#FormatCommand(
|
||||
let [l:temporary_file, l:command, l:file_created] = ale#command#FormatCommand(
|
||||
\ l:buffer,
|
||||
\ l:executable,
|
||||
\ l:command,
|
||||
\ l:read_buffer,
|
||||
\ function('s:CreateTemporaryFileForJob'),
|
||||
\)
|
||||
|
||||
if s:CreateTemporaryFileForJob(l:buffer, l:temporary_file)
|
||||
if l:file_created
|
||||
" If a temporary filename has been formatted in to the command, then
|
||||
" we do not need to send the Vim buffer to the command.
|
||||
let l:read_buffer = 0
|
||||
|
||||
@@ -172,7 +172,7 @@ function! ale#fix#RemoveManagedFiles(buffer) abort
|
||||
let g:ale_fix_buffer_data[a:buffer].temporary_directory_list = []
|
||||
endfunction
|
||||
|
||||
function! s:CreateTemporaryFileForJob(buffer, temporary_file, input) abort
|
||||
function! s:CreateTemporaryFileForJob(input, buffer, temporary_file) abort
|
||||
if empty(a:temporary_file)
|
||||
" There is no file, so we didn't create anything.
|
||||
return 0
|
||||
@@ -218,13 +218,13 @@ function! s:RunJob(options) abort
|
||||
return 1
|
||||
endif
|
||||
|
||||
let [l:temporary_file, l:command] = ale#command#FormatCommand(
|
||||
let [l:temporary_file, l:command, l:file_created] = ale#command#FormatCommand(
|
||||
\ l:buffer,
|
||||
\ '',
|
||||
\ l:command,
|
||||
\ l:read_buffer,
|
||||
\ function('s:CreateTemporaryFileForJob', [l:input]),
|
||||
\)
|
||||
call s:CreateTemporaryFileForJob(l:buffer, l:temporary_file, l:input)
|
||||
|
||||
let l:command = ale#job#PrepareCommand(l:buffer, l:command)
|
||||
let l:job_options = {
|
||||
|
||||
@@ -182,7 +182,7 @@ function! ale#lsp_linter#StartLSP(buffer, linter) abort
|
||||
|
||||
let l:command = ale#linter#GetCommand(a:buffer, a:linter)
|
||||
" Format the command, so %e can be formatted into it.
|
||||
let l:command = ale#command#FormatCommand(a:buffer, l:executable, l:command, 0)[1]
|
||||
let l:command = ale#command#FormatCommand(a:buffer, l:executable, l:command, 0, {-> 0})[1]
|
||||
let l:command = ale#job#PrepareCommand(a:buffer, l:command)
|
||||
let l:ready = ale#lsp#StartProgram(l:conn_id, l:executable, l:command)
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user