mirror of
https://github.com/atom/atom.git
synced 2026-02-14 08:35:11 -05:00
Delete end pair when begin pair is backspaced
This commit is contained in:
@@ -47,6 +47,20 @@ class LanguageMode
|
||||
@bracketAnchorRanges.push @editSession.addAnchorRange(range)
|
||||
false
|
||||
|
||||
_.adviseBefore @editSession, 'backspace', =>
|
||||
return if @editSession.hasMultipleCursors()
|
||||
return unless @editSession.getSelection().isEmpty()
|
||||
|
||||
cursorBufferPosition = @editSession.getCursorBufferPosition()
|
||||
previousCharacter = @editSession.getTextInBufferRange([cursorBufferPosition.add([0, -1]), cursorBufferPosition])
|
||||
nextCharacter = @editSession.getTextInBufferRange([cursorBufferPosition, cursorBufferPosition.add([0,1])])
|
||||
if @pairedCharacters[previousCharacter] is nextCharacter
|
||||
@editSession.transact =>
|
||||
@editSession.moveCursorLeft()
|
||||
@editSession.delete()
|
||||
@editSession.delete()
|
||||
false
|
||||
|
||||
reloadGrammar: ->
|
||||
path = @buffer.getPath()
|
||||
pathContents = @buffer.cachedDiskContents
|
||||
|
||||
Reference in New Issue
Block a user