Handle absolute windows paths in Grep/Ag/Ripgrep sink process (#1038)

Fix #1037

Function `ag_to_qf` is used to parse line produced by Grep, Ag or
Ripgrep. Implementation in quesition split it using regexp that doesn't
work for windows absolut paths.

A better approach is to use `matchlist` function.
This commit is contained in:
Maxim Kim
2020-06-01 06:16:18 +03:00
committed by GitHub
parent 7a655179a4
commit 5aa5977d74

View File

@@ -669,11 +669,10 @@ endfunction
" Ag / Rg
" ------------------------------------------------------------------
function! s:ag_to_qf(line, has_column)
let parts = split(a:line, '[^:]\zs:\ze[^:]')
let text = join(parts[(a:has_column ? 3 : 2):], ':')
let dict = {'filename': &acd ? fnamemodify(parts[0], ':p') : parts[0], 'lnum': parts[1], 'text': text}
let parts = matchlist(a:line, '\(.\{-}\):\(\d\+\)\%(:\(\d\+\)\)\?\%(:\(.*\)\)\?')
let dict = {'filename': &acd ? fnamemodify(parts[1], ':p') : parts[1], 'lnum': parts[2], 'text': parts[4]}
if a:has_column
let dict.col = parts[2]
let dict.col = parts[3]
endif
return dict
endfunction