mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Ignore bracket matching when there are multiple cursors
This commit is contained in:
@@ -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 '('
|
||||
|
||||
@@ -307,6 +307,9 @@ class EditSession
|
||||
removeAnchorRange: (anchorRange) ->
|
||||
_.remove(@anchorRanges, anchorRange)
|
||||
|
||||
hasMultipleCursors: ->
|
||||
@getCursors().length > 1
|
||||
|
||||
getCursors: -> new Array(@cursors...)
|
||||
|
||||
getCursor: (index=0) ->
|
||||
|
||||
@@ -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])])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user