     return unless @isCursorOnTag()
 
     ranges = null
-    endPosition = @editor.getCursor().getCurrentWordBufferRange(wordRegex: /[^>]*/).end
-    @editor.backwardsScanInBufferRange /(<(\/?))([^\s>]+)([\s>]|$)/, [[0, 0], endPosition], ({match, range, stop}) =>
+    endPosition = @editor.getCursor().getCurrentWordBufferRange({@wordRegex}).end
+    @editor.backwardsScanInBufferRange @tagPattern, [[0, 0], endPosition], ({match, range, stop}) =>
       stop()
 
       [entireMatch, prefix, isClosingTag, tagName, suffix] = match

    unpairedCount = 0
    @editor.scanInBufferRange @getTagPattern(tagName), scanRange, ({match, range, stop}) =>
      return if @isRangeCommented(range)
      if match[1]
        unpairedCount++
      else

  constructor: (@editorView) ->
    {@editor} = @editorView

    @tagPattern = /(<(\/?))([^\s>]+)([\s>]|$)/
    @wordRegex = /[^>]*/
    @tagSelector = new ScopeSelector('meta.tag | punctuation.definition.tag')
    @commentSelector = new ScopeSelector('comment.*')

