Skip to content

Commit

Permalink
Break undo only if a snippet gets expanded.
Browse files Browse the repository at this point in the history
Instead of creating a new undo point always, this gets done now only if
a snippet gets expanded.
This means that "foobarbaz<tab>" won't break undo (with a non-change
point).

See the discussion at
MarcWeber@73a7255
  • Loading branch information
blueyed committed Apr 25, 2011
1 parent 23f1cb7 commit 824f902
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion after/plugin/snipMate.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let s:did_snips_mappings = 1
"
" You can safely adjust these mappings to your preferences (as explained in
" :help snipMate-remap).
ino <silent> <tab> <c-g>u<c-r>=TriggerSnippet()<cr>
ino <silent> <tab> <c-r>=TriggerSnippet()<cr>
snor <silent> <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>
ino <silent> <s-tab> <c-r>=BackwardsSnippet()<cr>
snor <silent> <s-tab> <esc>i<right><c-r>=BackwardsSnippet()<cr>
Expand Down
1 change: 1 addition & 0 deletions plugin/snipMate.vim
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ fun! TriggerSnippet()
" If word is a trigger for a snippet, delete the trigger & expand
" the snippet.
if snippet != ''
let &undolevels = &undolevels " create new undo point
let col = col('.') - len(trigger)
sil exe 's/\V'.escape(trigger, '/\.').'\%#//'
return snipMate#expandSnip(snippet, col)
Expand Down

0 comments on commit 824f902

Please sign in to comment.