Fix #518 Fix handling of spaces in filenames for various linters
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: Error handling for flake8, etc.
|
||||
|
||||
let s:path_pattern = '[a-zA-Z]\?\\\?:\?[[:alnum:]/\.\-_]\+'
|
||||
|
||||
function! ale#handlers#python#HandlePEP8Format(buffer, lines) abort
|
||||
" Matches patterns line the following:
|
||||
"
|
||||
@@ -10,7 +8,7 @@ function! ale#handlers#python#HandlePEP8Format(buffer, lines) abort
|
||||
"
|
||||
" stdin:6:6: E111 indentation is not a multiple of four
|
||||
" test.yml:35: [EANSIBLE0002] Trailing whitespace
|
||||
let l:pattern = '^' . s:path_pattern . ':\(\d\+\):\?\(\d\+\)\?: \[\?\(\([[:alpha:]]\)[[:alnum:]]\+\)\]\? \(.*\)$'
|
||||
let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):?(\d+)?: \[?([[:alnum:]]+)\]? (.*)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
@@ -30,8 +28,8 @@ function! ale#handlers#python#HandlePEP8Format(buffer, lines) abort
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:code . ': ' . l:match[5],
|
||||
\ 'type': l:match[4] ==# 'E' ? 'E' : 'W',
|
||||
\ 'text': l:code . ': ' . l:match[4],
|
||||
\ 'type': l:code[:0] ==# 'E' ? 'E' : 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: Error handling for errors in a Unix format.
|
||||
|
||||
let s:path_pattern = '[a-zA-Z]\?\\\?:\?[[:alnum:]/\.\-_]\+'
|
||||
|
||||
function! s:HandleUnixFormat(buffer, lines, type) abort
|
||||
let l:pattern = '^' . s:path_pattern . ':\(\d\+\):\?\(\d\+\)\?:\? \?\(.\+\)$'
|
||||
let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):?(\d+)?:? ?(.+)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
|
||||
@@ -55,3 +55,30 @@ endfunction
|
||||
function! ale#path#BufferCdString(buffer) abort
|
||||
return ale#path#CdString(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
endfunction
|
||||
|
||||
" Return 1 if a path is an absolute path.
|
||||
function! ale#path#IsAbsolute(filename) abort
|
||||
return match(a:filename, '^\v/|^[a-zA-Z]:\\') == 0
|
||||
endfunction
|
||||
|
||||
" Given a directory and a filename, resolve the path, which may be relative
|
||||
" or absolute, and get an absolute path to the file, following symlinks.
|
||||
function! ale#path#Resolve(directory, filename) abort
|
||||
return resolve(
|
||||
\ ale#path#IsAbsolute(a:filename)
|
||||
\ ? a:filename
|
||||
\ : a:directory . '/' . a:filename
|
||||
\)
|
||||
endfunction
|
||||
|
||||
" Given a buffer number and a relative or absolute path, return 1 if the
|
||||
" two paths represent the same file on disk.
|
||||
function! ale#path#IsBufferPath(buffer, filename) abort
|
||||
let l:buffer_filename = expand('#' . a:buffer . ':p')
|
||||
let l:resolved_filename = ale#path#Resolve(
|
||||
\ fnamemodify(l:buffer_filename, ':h'),
|
||||
\ a:filename
|
||||
\)
|
||||
|
||||
return resolve(l:buffer_filename) == l:resolved_filename
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user