1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 22:20:06 +08:00

Fixed: fix a bug in markdown_insert_url. (#2620)

* Fixed: fix a bug in markdown_insert_url.

* Fix: fix a bug when the '< and '> in two different lines.
This commit is contained in:
Lin Kun 2019-02-23 08:19:01 +08:00 committed by Wang Shidong
parent 8974e91873
commit efc9d28cf2

View File

@ -103,18 +103,24 @@ endfunction
function! s:markdown_insert_url(visual) abort
if !empty(@+)
let l:save_register_unnamed = @"
if a:visual
normal! gvx
else
normal! diw
let l:save_edge_left = getpos("'<")
let l:save_edge_right = getpos("'>")
if !a:visual
execute "normal! viw\<esc>"
endif
let l:paste = (col("'>") == col("$") - 1 ? 'p' : 'P')
normal! gvx
let @" = '[' . @" . '](' . @+ . ')'
if col('.') == col('$') - 1
normal! p
else
normal! P
endif
execute 'normal! ' . l:paste
let @" = l:save_register_unnamed
if a:visual
let l:save_edge_left[2] += 1
if l:save_edge_left[1] == l:save_edge_right[1]
let l:save_edge_right[2] += 1
endif
endif
call setpos("'<", l:save_edge_left)
call setpos("'>", l:save_edge_right)
endif
endfunction