summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-02-07 16:24:41 +0000
committerw0rp <devw0rp@gmail.com>2019-02-07 16:24:41 +0000
commit2885c57e3e8c7e6a02017640a8ae39348b01def3 (patch)
tree0f4335285cbe2ddd0ed646798a40e0e94e7eec79 /ale_linters
parent0b9c0c22009a991c16b08973025f9de9013838ed (diff)
downloadale-2885c57e3e8c7e6a02017640a8ae39348b01def3.zip
Fix #2276 - Replace a potentially infinite loop for hie
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/haskell/hie.vim24
1 files changed, 9 insertions, 15 deletions
diff --git a/ale_linters/haskell/hie.vim b/ale_linters/haskell/hie.vim
index c1712039..cc85fbed 100644
--- a/ale_linters/haskell/hie.vim
+++ b/ale_linters/haskell/hie.vim
@@ -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