diff --git a/lib/bracket-matcher.coffee b/lib/bracket-matcher.coffee index 7326026..bd742d4 100644 --- a/lib/bracket-matcher.coffee +++ b/lib/bracket-matcher.coffee @@ -198,7 +198,13 @@ class BracketMatcher 'comment.documentation.heredoc.elixir' ] @interpolatedStringSelector = SelectorCache.get(segments.join(' | ')) - @interpolatedStringSelector.matches(@editor.getLastCursor().getScopeDescriptor().getScopesArray()) + + lastCursor = @editor.getLastCursor() + + return false if lastCursor.isAtBeginningOfLine() or lastCursor.isAtEndOfLine() + + @interpolatedStringSelector.matches(lastCursor.getScopeDescriptor().getScopesArray()) and + @interpolatedStringSelector.matches(@editor.scopeDescriptorForBufferPosition([lastCursor.getBufferRow(), lastCursor.getBufferColumn() - 1]).getScopesArray()) getInvertedPairedCharacters: -> return @invertedPairedCharacters if @invertedPairedCharacters diff --git a/spec/bracket-matcher-spec.coffee b/spec/bracket-matcher-spec.coffee index e896597..536749c 100644 --- a/spec/bracket-matcher-spec.coffee +++ b/spec/bracket-matcher-spec.coffee @@ -874,6 +874,33 @@ describe "bracket matching", -> editor.undo() expect(editor.getText()).toBe 'foo = ""' + it "should not insert curly braces right before doubly quoted string", -> + editor.insertText "foo = " + editor.insertText '"' + editor.moveLeft() + editor.insertText "#" + expect(editor.getText()).toBe 'foo = #""' + + it "should not insert curly braces right after double quoted string", -> + editor.insertText "foo = " + editor.moveLeft() + editor.insertText '"' + editor.moveRight() + editor.insertText "#" + expect(editor.getText()).toBe 'foo = ""# ' + + it "should not insert curly braces right before doubly quoted string at the beginning of a line", -> + editor.insertText '"' + editor.moveLeft() + editor.insertText "#" + expect(editor.getText()).toBe '#""' + + it "should not insert curly braces right after doubly quoted string at the end of a line", -> + editor.insertText '"' + editor.moveRight() + editor.insertText "#" + expect(editor.getText()).toBe '""#' + it "should not insert curly braces inside singly quoted string", -> editor.insertText "foo = " editor.insertText "'"