mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
Honor the ‘onlyHead’ option for line and line-number decorations
This commit is contained in:
parent
af8c38ad80
commit
c4b5a0f411
@ -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]])
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user