mirror of
https://github.com/atom/atom.git
synced 2026-02-07 13:14:55 -05:00
Quotes only automatically close if they are opened after a non-word character.
This commit is contained in:
@@ -24,12 +24,13 @@ class LanguageMode
|
||||
return true if @editSession.hasMultipleCursors()
|
||||
|
||||
cursorBufferPosition = @editSession.getCursorBufferPosition()
|
||||
previousCharachter = @editSession.getTextInBufferRange([cursorBufferPosition.add([0, -1]), cursorBufferPosition])
|
||||
nextCharachter = @editSession.getTextInBufferRange([cursorBufferPosition, cursorBufferPosition.add([0,1])])
|
||||
|
||||
hasWordAfterCursor = /\w/.test(nextCharachter)
|
||||
cursorInsideString = @getTokenizedBuffer().isBufferPositionInsideString(cursorBufferPosition)
|
||||
hasWordBeforeCursor = /\w/.test(previousCharachter)
|
||||
|
||||
autoCompleteOpeningBracket = @isOpeningBracket(text) and not hasWordAfterCursor and not cursorInsideString
|
||||
autoCompleteOpeningBracket = @isOpeningBracket(text) and not hasWordAfterCursor and not (@isQuote(text) and hasWordBeforeCursor)
|
||||
skipOverExistingClosingBracket = false
|
||||
if @isClosingBracket(text) and nextCharachter == text
|
||||
if bracketAnchorRange = @bracketAnchorRanges.filter((anchorRange) -> anchorRange.getBufferRange().end.isEqual(cursorBufferPosition))[0]
|
||||
@@ -50,6 +51,9 @@ class LanguageMode
|
||||
getTokenizedBuffer: ->
|
||||
@editSession.tokenizedBuffer
|
||||
|
||||
isQuote: (string) ->
|
||||
/'|"/.test(string)
|
||||
|
||||
isOpeningBracket: (string) ->
|
||||
@pairedCharacters[string]?
|
||||
|
||||
|
||||
@@ -116,10 +116,6 @@ class TokenizedBuffer
|
||||
iterator(token, startOfToken, { stop }) if bufferRange.containsPoint(startOfToken)
|
||||
return unless keepLooping
|
||||
|
||||
isBufferPositionInsideString: (bufferPosition) ->
|
||||
if lastScope = _.last(@scopesForPosition(bufferPosition))
|
||||
/^string\./.test(lastScope)
|
||||
|
||||
findOpeningBracket: (startBufferPosition) ->
|
||||
range = [[0,0], startBufferPosition]
|
||||
position = null
|
||||
|
||||
Reference in New Issue
Block a user