Ignore bracket matching when there are multiple cursors

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-08-01 09:40:50 -07:00
parent 97b492edfc
commit a589557aaa
3 changed files with 16 additions and 0 deletions

View File

@@ -14,6 +14,17 @@ describe "LanguageMode", ->
{ buffer, languageMode } = editSession
describe "matching character insertion", ->
describe "when there are multiple cursors", ->
it "inserts ) at each cursor", ->
editSession.buffer.setText("()\nab\n[]\n12")
editSession.setCursorBufferPosition([3, 1])
editSession.addCursorAtBufferPosition([2, 1])
editSession.addCursorAtBufferPosition([1, 1])
editSession.addCursorAtBufferPosition([0, 1])
editSession.insertText ')'
expect(editSession.buffer.getText()).toBe "())\na)b\n[)]\n1)2"
describe "when ( is inserted", ->
it "inserts a matching ) following the cursor", ->
editSession.insertText '('

View File

@@ -307,6 +307,9 @@ class EditSession
removeAnchorRange: (anchorRange) ->
_.remove(@anchorRanges, anchorRange)
hasMultipleCursors: ->
@getCursors().length > 1
getCursors: -> new Array(@cursors...)
getCursor: (index=0) ->

View File

@@ -17,6 +17,8 @@ class LanguageMode
@aceAdaptor = new AceAdaptor(@editSession)
_.adviseBefore @editSession, 'insertText', (text) =>
return true if @editSession.hasMultipleCursors()
cursorBufferPosition = @editSession.getCursorBufferPosition()
nextCharachter = @editSession.getTextInBufferRange([cursorBufferPosition, cursorBufferPosition.add([0, 1])])