Skip to content

Commit

Permalink
Fix #2276 - Replace a potentially infinite loop for hie
Browse files Browse the repository at this point in the history
  • Loading branch information
w0rp committed Feb 7, 2019
1 parent 0ed3fbc commit 0c6370f
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions ale_linters/haskell/hie.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,20 @@ function! ale_linters#haskell#hie#GetProjectRoot(buffer) abort

" If it's empty, search for the cabal file
if empty(l:project_file)
let l:cabal_file = fnamemodify(bufname(a:buffer), ':p:h')
let l:paths = ''

while empty(matchstr(l:cabal_file, '^\(\/\|\(\w:\\\)\)$'))
let l:cabal_file = fnamemodify(l:cabal_file, ':h')
let l:paths = l:paths . l:cabal_file . ','
endwhile

" Search all of the paths except for the root filesystem path.
let l:paths = join(
\ ale#path#Upwards(expand('#' . a:buffer . ':p:h'))[:-2],
\ ','
\)
let l:project_file = globpath(l:paths, '*.cabal')
endif

" Either extract the project directory or take the current working
" directory
if !empty(l:project_file)
let l:project_file = fnamemodify(l:project_file, ':h')
else
let l:project_file = expand('#' . a:buffer . ':p:h')
" If we still can't find one, use the current file.
if empty(l:project_file)
let l:project_file = expand('#' . a:buffer . ':p')
endif

return l:project_file
return fnamemodify(l:project_file, ':h')
endfunction

function! ale_linters#haskell#hie#GetCommand(buffer) abort
Expand Down

0 comments on commit 0c6370f

Please sign in to comment.