           @editor.delete()
           # if on the same line and the cursor is in front of an end pair
           # offset by one to make up for the missing character
-          if position.row is matchPosition.row and endPairMatches.hasOwnProperty(currentPair)
+          if position.row is matchPosition.row and @endPairMatches.hasOwnProperty(currentPair)
             position = position.traverse([0, -1])
           @editor.setCursorBufferPosition(position)
           @editor.delete()

    else
      if startPosition = @findAnyStartPair(@editor.getCursorBufferPosition())
        startPair = @editor.getTextInRange(Range.fromPointWithDelta(startPosition, 0, 1))
        endPosition = @findMatchingEndPair(startPosition, startPair, startPairMatches[startPair])
      else if pair = @tagFinder.findEnclosingTags()
        {startRange, endRange} = pair
        if startRange.compare(endRange) > 0

{Range} = require 'atom'
TagFinder = require './tag-finder'

module.exports =
class BracketMatcherView
  startPairMatches:
    '(': ')'
    '[': ']'
    '{': '}'

  endPairMatches:
    ')': '('
    ']': '['
    '}': '{'

  constructor: (@editor, editorElement) ->
    @subscriptions = new CompositeDisposable
    @tagFinder = new TagFinder(@editor)
    @pairHighlighted = false
    @tagHighlighted = false

    @pairRegexes = {}
    @updatePairs()
    for startPair, endPair of @startPairMatches
      @pairRegexes[startPair] = new RegExp("[#{_.escapeRegExp(startPair + endPair)}]", 'g')

    # TODO: remove conditional when `onDidChangeText` ships on stable.
    if typeof @editor.getBuffer().onDidChangeText is "function"
      @subscriptions.add @editor.getBuffer().onDidChangeText =>
