Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Open
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
8 changes: 7 additions & 1 deletion lib/bracket-matcher.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions spec/bracket-matcher-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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 "'"
Expand Down