idanarye / vim-dutyl

Coordinate D tools to work together for you
http://www.vim.org/scripts/script.php?script_id=5003
79 stars 13 forks source link

Paths with spaces don't work #34

Closed MatthewCochrane closed 6 years ago

MatthewCochrane commented 8 years ago

When trying to use vim-dutyl in a path with spaces it gives an error saying it can't run dub describe.

A fix is to modify dutyl#util#runInDirectory to the following code. The fix uses substitute to replace all spaces in the path with an escaped space "\ ".

"lcd to the directory, run the function or command, and return to the current
"directory
function! dutyl#util#runInDirectory(directory,action,...) abort
    let l:cwd=getcwd()
    try 
        let l:directory = substitute(a:directory, "\ ", '\\ ', "g")
        execute 'lcd '.l:directory
        if type(function('tr'))==type(a:action)
            return call(a:action,a:000)
        elseif type('')==type(a:action)
            execute a:action
        endif
    finally
        let l:cwd = substitute(l:cwd, "\ ", '\\ ', "g")
        execute 'lcd '.l:cwd
    endtry
endfunction
idanarye commented 8 years ago

If you have a fix, why won't you make a pull request?