Skip to content
This repository was archived by the owner on Apr 6, 2018. It is now read-only.

suppress unwanted bracket matching #854

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/insert-mode.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# todo add specs with bracket-matcher for these two
copyCharacterFromAbove = (editor, vimState) ->
editor.transact ->
for cursor in editor.getCursors()
Expand Down
6 changes: 4 additions & 2 deletions lib/operators/input.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class Insert extends Operator
execute: ->
if @typingCompleted
return unless @typedText? and @typedText.length > 0
@editor.insertText(@typedText, normalizeLineEndings: true, autoIndent: true)
# todo add specs with bracket-matcher for this
@editor.insertText(@typedText, normalizeLineEndings: true, autoIndent: true, matchBrackets: false)
for cursor in @editor.getCursors()
cursor.moveLeft() unless cursor.isAtBeginningOfLine()
else
Expand All @@ -35,7 +36,8 @@ class ReplaceMode extends Insert
if @typingCompleted
return unless @typedText? and @typedText.length > 0
@editor.transact =>
@editor.insertText(@typedText, normalizeLineEndings: true)
# todo add specs with bracket-matcher for this
@editor.insertText(@typedText, normalizeLineEndings: true, matchBrackets: false)
toDelete = @typedText.length - @countChars('\n', @typedText)
for selection in @editor.getSelections()
count = toDelete
Expand Down
3 changes: 2 additions & 1 deletion lib/operators/put-operator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class Put extends Operator
@editor.moveToBeginningOfLine()
originalPosition = @editor.getCursorScreenPosition()

@editor.insertText(textToInsert)
# todo add specs with bracket-matcher for this
@editor.insertText(textToInsert, matchBrackets: false)

if originalPosition?
@editor.setCursorScreenPosition(originalPosition)
Expand Down
1 change: 1 addition & 0 deletions lib/operators/replace-operator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Replace extends OperatorWithInput

return

# todo add specs with bracket matcher, for both editor.replaceSelectedText and editor.setTextInBufferRange
@editor.transact =>
if @motion?
if _.contains(@motion.select(), true)
Expand Down
10 changes: 9 additions & 1 deletion lib/vim-state.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,13 @@ class VimState
@subscriptions.add @replaceModeListener = @editor.onWillInsertText @replaceModeInsertHandler
@subscriptions.add @replaceModeUndoListener = @editor.onDidInsertText @replaceModeUndoHandler

# todo add bracket matcher specs for replace mode
if @replaceModeBracketMatcherGuard ?= atom.packages.getActivePackage('bracket-matcher')
# suppress bracket matching in replace mode
_.adviseBefore @editor, 'insertText', (text, options) =>
options?.matchBrackets = false if not @destroyed and @mode is 'insert' and @submode is 'replace'
return true

replaceModeInsertHandler: (event) =>
chars = event.text?.split('') or []
selections = @editor.getSelections()
Expand Down Expand Up @@ -648,7 +655,8 @@ class VimState
# Returns nothing.
insertRegister: (name) ->
text = @getRegister(name)?.text
@editor.insertText(text) if text?
# todo add specs with bracket-matcher for this
@editor.insertText(text, groupUndo: true, matchBrackets: false) if text?

# Private: ensure the mode follows the state of selections
checkSelections: =>
Expand Down