Compare commits

..

3 Commits

Author SHA1 Message Date
w0rp
5556fcbd1c Stop the completion tests from failing randomly 2017-11-21 14:57:28 +00:00
w0rp
cf599f4470 #1149 Fix conversion from URIs to filenames on Windows 2017-11-21 14:56:37 +00:00
w0rp
e71d831119 Fix #1124 - Handle stack-build errors with leading spaces 2017-11-13 22:48:30 +00:00
6 changed files with 48 additions and 5 deletions

View File

@@ -282,6 +282,15 @@ function! s:TimerHandler(...) abort
endif
endfunction
" Stop any completion timer that is queued. This is useful for tests.
function! ale#completion#StopTimer() abort
if s:timer_id != -1
call timer_stop(s:timer_id)
endif
let s:timer_id = -1
endfunction
function! ale#completion#Queue() abort
let l:time = get(b:, 'ale_complete_done_time', 0)
@@ -298,9 +307,7 @@ function! ale#completion#Queue() abort
let b:ale_completion_info.request_id = 0
endif
if s:timer_id != -1
call timer_stop(s:timer_id)
endif
call ale#completion#StopTimer()
let s:timer_id = timer_start(g:ale_completion_delay, function('s:TimerHandler'))
endfunction

View File

@@ -19,7 +19,7 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort
" in Haskell error messages with the basename for this file.
let l:temp_filename_regex = s:temp_regex_prefix . l:basename
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+):(.*)?$'
let l:pattern = '\v^\s*([a-zA-Z]?:?[^:]+):(\d+):(\d+):(.*)?$'
let l:output = []
let l:corrected_lines = []

View File

@@ -185,5 +185,12 @@ function! ale#path#FromURI(uri) abort
let l:i = len('file://')
let l:encoded_path = a:uri[: l:i - 1] is# 'file://' ? a:uri[l:i :] : a:uri
return ale#uri#Decode(l:encoded_path)
let l:path = ale#uri#Decode(l:encoded_path)
" If the path is like /C:/foo/bar, it should be C:\foo\bar instead.
if l:path =~# '^/[a-zA-Z]:'
let l:path = substitute(l:path[1:], '/', '\\', 'g')
endif
return l:path
endfunction

View File

@@ -76,3 +76,25 @@ Execute(The ghc handler should handle ghc 7 output):
\ ale#path#Winify('src/Main.hs') . ':94:5:Error:',
\ ' Some other error',
\ ])
Execute(The ghc handler should handle stack 1.5.1 output):
call ale#test#SetFilename('src/Main.hs')
AssertEqual
\ [
\ {
\ 'lnum': 160,
\ 'col': 14,
\ 'type': 'E',
\ 'text': '• Expecting one fewer arguments to Exp Expected kind k0 -> *, but Exp has kind * • In the type Exp a | 160 | pattern F :: Exp a | ^^^^^',
\ },
\ ],
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
\ ' ' . ale#path#Winify('src/Main.hs') . ':160:14: error:',
\ ' • Expecting one fewer arguments to Exp',
\ ' Expected kind k0 -> *, but Exp has kind *',
\ ' • In the type Exp a',
\ ' |',
\ ' 160 | pattern F :: Exp a',
\ ' | ^^^^^',
\ ])

View File

@@ -41,6 +41,10 @@ After:
delfunction CheckCompletionCalled
" Stop any timers we left behind.
" This stops the tests from failing randomly.
call ale#completion#StopTimer()
runtime autoload/ale/completion.vim
runtime autoload/ale/lsp.vim

View File

@@ -2,6 +2,9 @@ Execute(ale#path#ToURI should work for Windows paths):
AssertEqual 'file:///C:/foo/bar/baz.tst', ale#path#ToURI('C:\foo\bar\baz.tst')
AssertEqual 'foo/bar/baz.tst', ale#path#ToURI('foo\bar\baz.tst')
Execute(ale#path#FromURI should work for Windows paths):
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('file:///C:/foo/bar/baz.tst')
Execute(ale#path#ToURI should work for Unix paths):
AssertEqual 'file:///foo/bar/baz.tst', ale#path#ToURI('/foo/bar/baz.tst')
AssertEqual 'foo/bar/baz.tst', ale#path#ToURI('foo/bar/baz.tst')