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

View file

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