#283 Fix linting buffers with no filename, by creating a filename with a guess for the file extension

This commit is contained in:
w0rp
2017-02-13 10:36:38 +00:00
parent 3aa1d57b57
commit 5cdd1498b4
3 changed files with 98 additions and 3 deletions

View File

@@ -286,11 +286,17 @@ function! ale#engine#EscapeCommandPart(command_part) abort
endfunction
function! s:TemporaryFilename(buffer) abort
let l:filename = fnamemodify(bufname(a:buffer), ':t')
if empty(l:filename)
" If the buffer's filename is empty, create a dummy filename.
let l:ft = getbufvar(a:buffer, '&filetype')
let l:filename = 'file' . ale#filetypes#GuessExtension(l:ft)
endif
" Create a temporary filename, <temp_dir>/<original_basename>
" The file itself will not be created by this function.
return tempname()
\ . (has('win32') ? '\' : '/')
\ . fnamemodify(bufname(a:buffer), ':t')
return tempname() . (has('win32') ? '\' : '/') . l:filename
endfunction
" Given a command string, replace every...