Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
fix tyru#18: use :!start on MS Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
tyru committed Mar 11, 2013
1 parent 5b01f75 commit 98f082c
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions autoload/openbrowser.vim
Expand Up @@ -24,13 +24,13 @@ elseif g:__openbrowser_platform.macunix
endfunction
elseif g:__openbrowser_platform.mswin
function! s:get_default_open_commands()
return ['cmd.exe']
return ['rundll32']
endfunction
function! s:get_default_open_rules()
" NOTE: On MS Windows, 'start' command is not executable.
" NOTE: If &shellslash == 1,
" `shellescape(uri)` uses single quotes not double quote.
return {'cmd.exe': 'cmd /c start rundll32 url.dll,FileProtocolHandler {openbrowser#shellescape(uri)}'}
return {'rundll32': 'rundll32 url.dll,FileProtocolHandler {uri}'}
endfunction
elseif g:__openbrowser_platform.unix
function! s:get_default_open_commands()
Expand Down Expand Up @@ -592,6 +592,23 @@ if s:use_vimproc && globpath(&rtp, 'autoload/vimproc.vim') !=# ''
function! s:system(...)
return call('vimproc#system', a:000)
endfunction
elseif g:__openbrowser_platform.mswin
function! s:system(...)
let args = map(copy(a:000), 's:escape_cmdline_special(v:val)')
execute '!start' join(args, ' ')
endfunction

" :help cmdline-special
" :help expand()
function! s:escape_cmdline_special(str)
let shellslash = &l:shellslash
setlocal noshellslash
try
return substitute(a:str, '[%#<>]', '\\\0', 'g')
finally
let &l:shellslash = shellslash
endtry
endfunction
else
function! s:system(...)
return call('system', a:000)
Expand Down

0 comments on commit 98f082c

Please sign in to comment.