           lineId = presenter.linesByScreenRow.get(row)?.id
           tilesState[presenter.tileForRow(row)]?.lines[lineId]
 
-        tokensIncludeTag = (tokens, tag) ->
-          includeTag = false
-          for {openTags, closeTags} in tokens
-            includeTag = true for openTag in openTags when openTag.indexOf(tag) isnt -1
-            includeTag = true for closeTag in closeTags when closeTag.indexOf(tag) isnt -1
-          includeTag
+        tagsForCodes = (presenter, tagCodes) ->
+          openTags = []
+          closeTags = []
+          for tagCode in tagCodes when tagCode < 0 # skip text codes
+            if presenter.isOpenTagCode(tagCode)
+              openTags.push(presenter.tagForCode(tagCode))
+            else
+              closeTags.push(presenter.tagForCode(tagCode))
+          {openTags, closeTags}
 
         tiledContentContract (presenter) -> getState(presenter).content
 


            expectStateUpdate presenter, -> buffer.insert([2, 0], "hello\nworld\n")

            expectValues lineStateForScreenRow(presenter, 1), {
              screenRow: 1, tokens: [
                {closeTags: [], openTags: ['text.plain.null-grammar', 'leading-whitespace'], text: '  '},
                {closeTags: ['leading-whitespace'], openTags: [], text: 'var sort = function(items) {'},
                {closeTags: ['text.plain.null-grammar'], openTags: [], text : ''}
              ]
            }
            expectValues lineStateForScreenRow(presenter, 2), {
              screenRow: 2, tokens: [
                {closeTags: [], openTags: ['text.plain.null-grammar'], text: 'hello'},
                {closeTags: ['text.plain.null-grammar'], openTags: [], text: ''}
              ]
            }
            expectValues lineStateForScreenRow(presenter, 3), {
              screenRow: 3, tokens: [
                {closeTags: [], openTags: ['text.plain.null-grammar'], text: 'world'},
                {closeTags: ['text.plain.null-grammar'], openTags: [], text: ''}
              ]
            }

          it "includes the .endOfLineInvisibles if the editor.showInvisibles config option is true", ->
            editor.setText("hello\nworld\r\n")
            presenter = buildPresenter(explicitHeight: 25, scrollTop: 0, lineHeight: 10)
            expect(tokensIncludeTag(lineStateForScreenRow(presenter, 0).tokens, 'eol')).toBe(false)
            expect(tokensIncludeTag(lineStateForScreenRow(presenter, 1).tokens, 'eol')).toBe(false)

            atom.config.set('editor.showInvisibles', true)
            presenter = buildPresenter(explicitHeight: 25, scrollTop: 0, lineHeight: 10)
            expect(tokensIncludeTag(lineStateForScreenRow(presenter, 0).tokens, 'eol')).toBe(true)
            expect(tokensIncludeTag(lineStateForScreenRow(presenter, 1).tokens, 'eol')).toBe(true)

          describe ".blockDecorations", ->
            it "contains all block decorations that are present before/after a line, both initially and when decorations change", ->

            presenter.setExplicitHeight(3)

            expect(lineStateForScreenRow(presenter, 2)).toBeUndefined()
            expectValues lineStateForScreenRow(presenter, 3), {screenRow: 3, tagCodes: editor.screenLineForScreenRow(3).tagCodes}
            expectValues lineStateForScreenRow(presenter, 4), {screenRow: 4, tagCodes: editor.screenLineForScreenRow(4).tagCodes}
            expectValues lineStateForScreenRow(presenter, 5), {screenRow: 5, tagCodes: editor.screenLineForScreenRow(5).tagCodes}
            expectValues lineStateForScreenRow(presenter, 6), {screenRow: 6, tagCodes: editor.screenLineForScreenRow(6).tagCodes}
            expectValues lineStateForScreenRow(presenter, 7), {screenRow: 7, tagCodes: editor.screenLineForScreenRow(7).tagCodes}
            expectValues lineStateForScreenRow(presenter, 8), {screenRow: 8, tagCodes: editor.screenLineForScreenRow(8).tagCodes}
            expect(lineStateForScreenRow(presenter, 9)).toBeUndefined()

          it "updates when the editor's content changes", ->
