Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WalterGR/c77f72093368a478dfa5 to your computer and use it in GitHub Desktop.
Save WalterGR/c77f72093368a478dfa5 to your computer and use it in GitHub Desktop.
Patch to Atom's bracket-matcher package (at revision 57b78b1) to look at the previous character first when matching closing punctuation
77c77,78
< {position, currentPair, matchingPair} = @findCurrentPair(startPairMatches)
---
> # Look for opening punctuation, checking the current character, then the previous character.
> {position, currentPair, matchingPair} = @findCurrentPair(startPairMatches, 0, -1)
81c82,83
< {position, currentPair, matchingPair} = @findCurrentPair(endPairMatches)
---
> # Look for closing punctuation, checking the previous character then the current character.
> {position, currentPair, matchingPair} = @findCurrentPair(endPairMatches, -1, 0)
182,183c184,188
< findCurrentPair: (matches) ->
< position = @editor.getCursorBufferPosition()
---
> findCurrentPair: (matches, firstColumnOffset, secondColumnOffset) ->
> currentPosition = @editor.getCursorBufferPosition()
>
> # Look at the first character to check.
> position = currentPosition.traverse([0, firstColumnOffset])
184a190,191
>
> # If the character doesn't have a pair in `matches`, look at the second character to check.
186c193
< position = position.traverse([0, -1])
---
> position = currentPosition.traverse([0, secondColumnOffset])
187a195
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment