When a snippet expansion is redone, tab stops are restored

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-07-06 11:50:42 -07:00
parent 5554d15bdb
commit d6912c5913
3 changed files with 22 additions and 1 deletions

View File

@@ -54,3 +54,7 @@ class SnippetExpansion
destroy: ->
anchorRange.destroy() for anchorRange in @tabStopAnchorRanges
@editSession.snippetExpansion = null
restoreTabStops: ->
@tabStopAnchorRanges = @tabStopAnchorRanges.map (anchorRange) =>
@editSession.addAnchorRange(anchorRange.getBufferRange())

View File

@@ -29,9 +29,13 @@ module.exports =
prefix = editSession.getLastCursor().getCurrentWordPrefix()
if snippet = @snippetsByExtension[editSession.getFileExtension()][prefix]
editSession.transact ->
editSession.snippetExpansion = new SnippetExpansion(snippet, editSession)
snippetExpansion = new SnippetExpansion(snippet, editSession)
editSession.snippetExpansion = snippetExpansion
editSession.pushOperation
undo: -> editSession.snippetExpansion.destroy()
redo: ->
editSession.snippetExpansion = snippetExpansion
snippetExpansion.restoreTabStops()
else
e.abortKeyBinding()