Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Seems to work locally. But I don't know vimscript, so definitely should be reviewed.
  • Loading branch information
dubiousjim committed Feb 16, 2022
1 parent 2f57074 commit 55ce281
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions autoload/pandoc/keyboard/styles.vim
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ function! pandoc#keyboard#styles#ToggleOperator(type, ends) abort
let reg = 'p'
let reg_save = getreg(reg)
if a:type ==# 'v'
execute 'normal! `<'.a:type.'`>'.'"'.reg.'x'
execute 'normal! `>'
let was_eoln = s:IsCursorAtEndofNonEmptyLine()
execute 'normal! '.a:type.'`<'.'"'.reg.'x'
elseif a:type ==# 'char'
let cline = getline('.')
let ccol = getpos('.')[2]
Expand All @@ -88,20 +90,21 @@ function! pandoc#keyboard#styles#ToggleOperator(type, ends) abort
" inside a word
execute 'normal! `[EBv`]BE'.'"'.reg.'x'
endif
let was_eoln = s:IsCursorAtEndofNonEmptyLine()
else
return
endif
let match_data = matchlist(getreg(reg), '\('.s:EscapeEnds(a:ends).'\)\(.*\)\('.s:EscapeEnds(a:ends).'\)')
if len(match_data) == 0
call setreg(reg, a:ends.getreg(reg).a:ends)
if s:IsCursorAtEndofNonEmptyLine()
if was_eoln
execute 'normal "'.reg.'p'
else
execute 'normal "'.reg.'P'
endif
else
call setreg(reg, match_data[2])
if s:IsCursorAtEndofNonEmptyLine()
if was_eoln
execute 'normal "'.reg.'p'
else
execute 'normal "'.reg.'P'
Expand Down

0 comments on commit 55ce281

Please sign in to comment.