Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

make parsing more robust (fixes #19)

if the output of ghc-mod cannot be parsed try to display what we got
and indicate to the user that there was a parse problem
  • Loading branch information...
commit de4a9e7263f3c044d264627df86b9f1f986de639 1 parent 005fd8e
@marcmo marcmo authored
Showing with 25 additions and 6 deletions.
  1. +25 −6 autoload/ghcmod.vim
View
31 autoload/ghcmod.vim
@@ -156,6 +156,13 @@ function! ghcmod#parse_make(lines, basedir)"{{{
for l:output in a:lines
let l:qf = {}
let l:m = matchlist(l:output, '^\(\f\+\):\(\d\+\):\(\d\+\):\s*\(.*\)$')
+ if len(l:m) < 4
+ let l:qf.bufnr = 0
+ let l:qf.type = 'E'
+ let l:qf.text = 'parse error in ghcmod! Could not parse the following ghc-mod output:' . l:output
+ call add(l:qflist, l:qf)
+ break
+ end
let [l:qf.filename, l:qf.lnum, l:qf.col, l:rest] = l:m[1 : 4]
let l:qf.filename = s:join_path(a:basedir, l:qf.filename)
if l:rest =~# '^Warning:'
@@ -168,12 +175,24 @@ function! ghcmod#parse_make(lines, basedir)"{{{
let l:qf.type = 'E'
endif
let l:texts = split(l:rest, '\n')
- let l:qf.text = l:texts[0]
- call add(l:qflist, l:qf)
-
- for l:text in l:texts[1 :]
- call add(l:qflist, {'text': l:text})
- endfor
+ if len(l:texts) > 0
+ let l:qf.text = l:texts[0]
+ call add(l:qflist, l:qf)
+ for l:text in l:texts[1 :]
+ call add(l:qflist, {'text': l:text})
+ endfor
+ else
+ let l:qf.filename = ''
+ let l:errortext = join(a:lines, "\n")
+ let l:qf.bufnr = 0
+ let l:qf.type = 'E'
+ let l:qf.text = 'parse error in ghcmod! Could not parse the following ghc-mod output:'
+ call add(l:qflist, l:qf)
+ for l:text in a:lines
+ call add(l:qflist, {'text': l:text})
+ endfor
+ break
+ endif
endfor
return l:qflist
endfunction"}}}
Please sign in to comment.
Something went wrong with that request. Please try again.