Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions plugin/mdip.vim
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,20 @@ function! mdip#MarkdownClipboardImage()
if tmpfile == 1
return
else
" let relpath = s:SaveNewFile(g:mdip_imgdir, tmpfile)
let extension = split(tmpfile, '\.')[-1]
let extension = split(tmpfile, '\.')[-1]
let relpath = g:mdip_imgdir_intext . '/' . g:mdip_tmpname . '.' . extension
execute "normal! i![" . g:mdip_tmpname[0:0]
let ipos = getcurpos()
execute "normal! a" . g:mdip_tmpname[1:] . "](" . relpath . ")"
call setpos('.', ipos)
execute "normal! vt]\<C-g>"
if &filetype == 'md' || &filetype == 'pandoc'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned by this approach. Better to separate file type logic from the function

execute "normal! i![" . g:mdip_tmpname[0:0]
let ipos = getcurpos()
execute "normal! a" . g:mdip_tmpname[1:] . "](" . relpath . ")"
call setpos('.', ipos)
execute "normal! vt]\<C-g>"
elseif &filetype == 'tex'
let ipos = getcurpos()
execute "normal! a" . relpath
call setpos('.', ipos)
execute "normal! vt]\<C-g>"
endif
endif
endfunction

Expand Down