Skip to content

Commit f7a7851

Browse files
committed
Pin default shell to cmd.exe on windows. Fix path seprator for windows.
1 parent 787be15 commit f7a7851

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

plugin/mdip.vim

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ function! s:SaveFileTMPLinux(imgdir, tmpname) abort
8989
endfunction
9090

9191
function! s:SaveFileTMPWin32(imgdir, tmpname) abort
92+
let shell_bak = &shell
93+
let shellcmdflag_bak = &shellcmdflag
94+
let &shell = 'cmd.exe'
95+
let &shellcmdflag = '/s /c'
96+
9297
let tmpfile = a:imgdir . '\' . a:tmpname . '.png'
9398
let tmpfile = substitute(tmpfile, '\\ ', ' ', 'g')
9499

@@ -99,6 +104,10 @@ function! s:SaveFileTMPWin32(imgdir, tmpname) abort
99104
let clip_command = "powershell -nologo -noprofile -noninteractive -sta \"".clip_command. "\""
100105

101106
silent call system(clip_command)
107+
108+
let &shell = shell_bak
109+
let &shellcmdflag = shellcmdflag_bak
110+
102111
if v:shell_error == 1
103112
return 1
104113
else
@@ -194,7 +203,7 @@ function! g:LatexPasteImage(relpath)
194203
endfunction
195204

196205
function! g:EmptyPasteImage(relpath)
197-
execute "normal! i" . a:relpath
206+
execute "normal! i" . a:relpath
198207
endfunction
199208

200209
let g:PasteImageFunction = 'g:MarkdownPasteImage'
@@ -228,7 +237,8 @@ function! mdip#MarkdownClipboardImage()
228237
else
229238
" let relpath = s:SaveNewFile(g:mdip_imgdir, tmpfile)
230239
let extension = split(tmpfile, '\.')[-1]
231-
let relpath = g:mdip_imgdir_intext . '/' . g:mdip_tmpname . '.' . extension
240+
let sep = has('win32') ? '\' : '/'
241+
let relpath = g:mdip_imgdir_intext . sep . g:mdip_tmpname . '.' . extension
232242
if call(get(g:, 'PasteImageFunction'), [relpath])
233243
return
234244
endif

0 commit comments

Comments
 (0)