diff --git a/lib/insert-mode.coffee b/lib/insert-mode.coffee index d600e7e2..c663bf99 100644 --- a/lib/insert-mode.coffee +++ b/lib/insert-mode.coffee @@ -1,3 +1,4 @@ +# todo add specs with bracket-matcher for these two copyCharacterFromAbove = (editor, vimState) -> editor.transact -> for cursor in editor.getCursors() diff --git a/lib/operators/input.coffee b/lib/operators/input.coffee index 73cbeceb..f7ac4610 100644 --- a/lib/operators/input.coffee +++ b/lib/operators/input.coffee @@ -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 @@ -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 diff --git a/lib/operators/put-operator.coffee b/lib/operators/put-operator.coffee index 611d6faa..25509a46 100644 --- a/lib/operators/put-operator.coffee +++ b/lib/operators/put-operator.coffee @@ -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) diff --git a/lib/operators/replace-operator.coffee b/lib/operators/replace-operator.coffee index 9cf44b3e..e099406c 100644 --- a/lib/operators/replace-operator.coffee +++ b/lib/operators/replace-operator.coffee @@ -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) diff --git a/lib/vim-state.coffee b/lib/vim-state.coffee index db59ee51..67e86063 100644 --- a/lib/vim-state.coffee +++ b/lib/vim-state.coffee @@ -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() @@ -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: =>