Skip to content

Commit

Permalink
Don't break undo with left/right cursor movement.
Browse files Browse the repository at this point in the history
  • Loading branch information
ytang committed Feb 17, 2016
1 parent b647ef5 commit 7f548cb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions plugin/auto-pairs.vim
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ function! AutoPairsInsert(key)

" Skip the character if current character is the same as input
if current_char == a:key
return "\<Right>"
return "\<C-G>U\<Right>"
end

if !g:AutoPairsFlyMode
" Skip the character if next character is space
if current_char == ' ' && next_char == a:key
return "\<Right>\<Right>"
return "\<C-G>U\<Right>\<C-G>U\<Right>"
end

" Skip the character if closed pair is next character
Expand All @@ -132,7 +132,7 @@ function! AutoPairsInsert(key)
" Fly Mode, and the key is closed-pairs, search closed-pair and jump
if g:AutoPairsFlyMode && has_key(b:AutoPairsClosedPairs, a:key)
if search(a:key, 'W')
return "\<Right>"
return "\<C-G>U\<Right>"
endif
endif

Expand All @@ -144,7 +144,7 @@ function! AutoPairsInsert(key)
let close = b:AutoPairs[open]

if current_char == close && open == close
return "\<Right>"
return "\<C-G>U\<Right>"
end

" Ignore auto close ' if follows a word
Expand All @@ -159,7 +159,7 @@ function! AutoPairsInsert(key)
let pprev_char = line[col('.')-3]
if pprev_char == open && prev_char == open
" Double pair found
return repeat(a:key, 4) . repeat("\<LEFT>", 3)
return repeat(a:key, 4) . repeat("\<C-G>U\<LEFT>", 3)
end
end

Expand Down Expand Up @@ -194,7 +194,7 @@ function! AutoPairsInsert(key)
endif
endif

return open.close."\<Left>"
return open.close."\<C-G>U\<Left>"
endfunction

function! AutoPairsDelete()
Expand Down Expand Up @@ -318,10 +318,10 @@ function! AutoPairsFastWrap()
else
call search(s:FormatChunk(followed_open_pair, followed_close_pair), 'We')
end
return "\<RIGHT>".inputed_close_pair."\<LEFT>"
return "\<C-G>U\<RIGHT>".inputed_close_pair."\<C-G>U\<LEFT>"
else
normal he
return "\<RIGHT>".current_char."\<LEFT>"
return "\<C-G>U\<RIGHT>".current_char."\<C-G>U\<LEFT>"
end
endfunction

Expand Down Expand Up @@ -388,7 +388,7 @@ function! AutoPairsSpace()
let cmd = ''
let cur_char =line[col('.')-1]
if has_key(g:AutoPairsParens, prev_char) && g:AutoPairsParens[prev_char] == cur_char
let cmd = "\<SPACE>\<LEFT>"
let cmd = "\<SPACE>\<C-G>U\<LEFT>"
endif
return "\<SPACE>".cmd
endfunction
Expand Down

0 comments on commit 7f548cb

Please sign in to comment.