Don't render cursor line decorations in mini editors

This commit is contained in:
Nathan Sobo
2017-03-15 20:46:46 -06:00
committed by Antonio Scandurra
parent 1427dbf540
commit 82feef9f68
2 changed files with 26 additions and 3 deletions

View File

@@ -251,6 +251,19 @@ describe('TextEditorComponent', () => {
expect(component.refs.gutterContainer).toBeUndefined()
expect(element.querySelector('gutter-container')).toBeNull()
})
it('does not render line decorations for the cursor line', async () => {
const {component, element, editor} = buildComponent({mini: true})
expect(element.querySelector('.line').classList.contains('cursor-line')).toBe(false)
editor.update({mini: false})
await component.getNextUpdatePromise()
expect(element.querySelector('.line').classList.contains('cursor-line')).toBe(true)
editor.update({mini: true})
await component.getNextUpdatePromise()
expect(element.querySelector('.line').classList.contains('cursor-line')).toBe(false)
})
})
describe('focus', () => {

View File

@@ -200,9 +200,7 @@ class TextEditor extends Model
@decorationManager = new DecorationManager(@displayLayer)
@decorateMarkerLayer(@selectionsMarkerLayer, type: 'cursor')
@decorateMarkerLayer(@selectionsMarkerLayer, type: 'line-number', class: 'cursor-line')
@decorateMarkerLayer(@selectionsMarkerLayer, type: 'line-number', class: 'cursor-line-no-selection', onlyHead: true, onlyEmpty: true)
@decorateMarkerLayer(@selectionsMarkerLayer, type: 'line', class: 'cursor-line', onlyEmpty: true)
@decorateCursorLine() unless @isMini()
@decorateMarkerLayer(@displayLayer.foldsMarkerLayer, {type: 'line-number', class: 'folded'})
@@ -225,6 +223,13 @@ class TextEditor extends Model
priority: 0
visible: lineNumberGutterVisible
decorateCursorLine: ->
@cursorLineDecorations = [
@decorateMarkerLayer(@selectionsMarkerLayer, type: 'line', class: 'cursor-line', onlyEmpty: true),
@decorateMarkerLayer(@selectionsMarkerLayer, type: 'line-number', class: 'cursor-line'),
@decorateMarkerLayer(@selectionsMarkerLayer, type: 'line-number', class: 'cursor-line-no-selection', onlyHead: true, onlyEmpty: true)
]
doBackgroundWork: (deadline) =>
if @displayLayer.doBackgroundWork(deadline)
@presenter?.updateVerticalDimensions()
@@ -297,6 +302,11 @@ class TextEditor extends Model
displayLayerParams.invisibles = @getInvisibles()
displayLayerParams.softWrapColumn = @getSoftWrapColumn()
displayLayerParams.showIndentGuides = @doesShowIndentGuide()
if @mini
decoration.destroy() for decoration in @cursorLineDecorations
@cursorLineDecorations = null
else
@decorateCursorLine()
when 'placeholderText'
if value isnt @placeholderText