From 7668985b43bb1d31933532e1a4f5e66329034c29 Mon Sep 17 00:00:00 2001 From: Benjamin Brandtner <37274870+BenjaminBrandtner@users.noreply.github.com> Date: Mon, 22 Oct 2018 20:23:07 +0200 Subject: [PATCH] Fixed system file handlers for windows Fixes #560 Opening external files containing spaces should now work on cmd and powershell. --- autoload/vimwiki/base.vim | 40 ++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index cf93366..6167060 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -220,22 +220,32 @@ endfunction function! vimwiki#base#system_open_link(url) " handlers function! s:win32_handler(url) - "http://vim.wikia.com/wiki/Opening_current_Vim_file_in_your_Windows_browser - "disable 'shellslash', otherwise the url will be enclosed in single quotes, - "which is problematic - "see https://github.com/vimwiki/vimwiki/issues/54#issuecomment-48011289 - if exists('+shellslash') - let old_ssl = &shellslash - set noshellslash - let url = shellescape(a:url, 1) - let &shellslash = old_ssl + "Disable shellslash for cmd and command.com, but enable for all other shells + "See Issue #560 + if (&shell =~? "cmd") || (&shell =~? "command.com") + + if exists('+shellslash') + let old_ssl = &shellslash + set noshellslash + let url = shellescape(a:url, 1) + let &shellslash = old_ssl + else + let url = shellescape(a:url, 1) + endif + execute 'silent ! start "Title" /B ' . url + else - let url = shellescape(a:url, 1) - endif - if &l:shell ==? "powershell" - execute 'silent ! start ' . a:url - else - execute 'silent ! start "Title" /B ' . a:url + + if exists('+shellslash') + let old_ssl = &shellslash + set shellslash + let url = shellescape(a:url, 1) + let &shellslash = old_ssl + else + let url = shellescape(a:url, 1) + endif + execute 'silent ! start ' . url + endif endfunction function! s:macunix_handler(url)