Honor the ‘onlyHead’ option for line and line-number decorations

This commit is contained in:
Nathan Sobo 2015-01-27 07:49:24 -07:00
parent af8c38ad80
commit c4b5a0f411
2 changed files with 20 additions and 0 deletions

View File

@ -387,6 +387,15 @@ describe "TextEditorPresenter", ->
expect(lineStateForScreenRow(presenter, 6).decorationClasses).toBeNull()
it "honors the 'onlyHead' option on line decorations", ->
presenter = new TextEditorPresenter(model: editor, clientHeight: 130, scrollTop: 0, lineHeight: 10, lineOverdrawMargin: 0)
marker = editor.markBufferRange([[4, 0], [6, 2]])
decoration = editor.decorateMarker(marker, type: 'line', class: 'a', onlyHead: true)
expect(lineStateForScreenRow(presenter, 4).decorationClasses).toBeNull()
expect(lineStateForScreenRow(presenter, 5).decorationClasses).toBeNull()
expect(lineStateForScreenRow(presenter, 6).decorationClasses).toEqual ['a']
it "does not decorate the last line of a non-empty line decoration range if it ends at column 0", ->
presenter = new TextEditorPresenter(model: editor, clientHeight: 130, scrollTop: 0, lineHeight: 10, lineOverdrawMargin: 0)
marker = editor.markBufferRange([[4, 0], [6, 0]])
@ -1058,6 +1067,15 @@ describe "TextEditorPresenter", ->
expect(lineNumberStateForScreenRow(presenter, 6).decorationClasses).toBeNull()
it "honors the 'onlyHead' option on line-number decorations", ->
presenter = new TextEditorPresenter(model: editor, clientHeight: 130, scrollTop: 0, lineHeight: 10, lineOverdrawMargin: 0)
marker = editor.markBufferRange([[4, 0], [6, 2]])
decoration = editor.decorateMarker(marker, type: 'line-number', class: 'a', onlyHead: true)
expect(lineNumberStateForScreenRow(presenter, 4).decorationClasses).toBeNull()
expect(lineNumberStateForScreenRow(presenter, 5).decorationClasses).toBeNull()
expect(lineNumberStateForScreenRow(presenter, 6).decorationClasses).toEqual ['a']
it "does not decorate the last line of a non-empty line-number decoration range if it ends at column 0", ->
presenter = new TextEditorPresenter(model: editor, clientHeight: 130, scrollTop: 0, lineHeight: 10, lineOverdrawMargin: 0)
marker = editor.markBufferRange([[4, 0], [6, 0]])

View File

@ -251,6 +251,7 @@ class TextEditorPresenter
properties = decoration.getProperties()
range = decoration.getMarker().getScreenRange()
continue if properties.onlyHead and decoration.getMarker().getHeadScreenPosition().row isnt row
continue unless range.intersectsRow(row)
if range.isEmpty()
continue if properties.onlyNonEmpty
@ -272,6 +273,7 @@ class TextEditorPresenter
properties = decoration.getProperties()
range = decoration.getMarker().getScreenRange()
continue if properties.onlyHead and decoration.getMarker().getHeadScreenPosition().row isnt row
continue unless range.intersectsRow(row)
if range.isEmpty()
continue if properties.onlyNonEmpty