fix CdString for MS Windows

This commit is contained in:
paihu 2018-10-22 21:17:57 +09:00
parent f57ad883f2
commit eae3f70e75
2 changed files with 19 additions and 5 deletions

View File

@ -65,7 +65,11 @@ endfunction
" Output 'cd <directory> && '
" This function can be used changing the directory for a linter command.
function! ale#path#CdString(directory) abort
if has('win32')
return 'cd /d ' . ale#Escape(a:directory) . ' && '
else
return 'cd ' . ale#Escape(a:directory) . ' && '
endif
endfunction
" Output 'cd <buffer_filename_directory> && '

View File

@ -8,11 +8,21 @@ After:
Execute(CdString should output the correct command string):
" We will check that escaping is done correctly for each platform.
if has('win32')
AssertEqual
\ 'cd /d "/foo bar/baz" && ',
\ ale#path#CdString('/foo bar/baz')
else
AssertEqual
\ has('unix') ? 'cd ''/foo bar/baz'' && ' : 'cd "/foo bar/baz" && ',
\ ale#path#CdString('/foo bar/baz')
endif
Execute(BufferCdString should output the correct command string):
call ale#test#SetFilename('foo.txt')
if has('win32')
AssertEqual 'cd /d ' .ale#Escape(g:dir) . ' && ', ale#path#BufferCdString(bufnr(''))
else
AssertEqual 'cd ' . ale#Escape(g:dir) . ' && ', ale#path#BufferCdString(bufnr(''))
endif