Fix spurious selections marker layer update to avoid extra render

This commit is contained in:
Nathan Sobo 2017-02-27 15:14:39 -07:00 committed by Antonio Scandurra
parent be7f4a5ffd
commit b362f746f8
2 changed files with 2 additions and 8 deletions

View File

@ -34,12 +34,6 @@ describe('TextEditorComponent', () => {
it('renders lines and line numbers for the visible region', async () => {
const {component, element, editor} = buildComponent({rowsPerTile: 3})
// TODO: An extra update is caused by marker layer events being asynchronous,
// so the cursor getting added triggers an update even though we created
// the component after this occurred. We should make marker layer events
// synchronous and batched on the transaction.
await component.getNextUpdatePromise()
expect(element.querySelectorAll('.line-number').length).toBe(13)
expect(element.querySelectorAll('.line').length).toBe(13)

View File

@ -210,7 +210,7 @@ class TextEditor extends Model
if @cursors.length is 0 and not suppressCursorCreation
initialLine = Math.max(parseInt(initialLine) or 0, 0)
initialColumn = Math.max(parseInt(initialColumn) or 0, 0)
@addCursorAtBufferPosition([initialLine, initialColumn])
@addCursorAtBufferPosition([initialLine, initialColumn], {suppressLayerUpdateEvent: true})
@languageMode = new LanguageMode(this)
@ -2140,7 +2140,7 @@ class TextEditor extends Model
#
# Returns a {Cursor}.
addCursorAtBufferPosition: (bufferPosition, options) ->
@selectionsMarkerLayer.markBufferPosition(bufferPosition, {invalidate: 'never'})
@selectionsMarkerLayer.markBufferPosition(bufferPosition, Object.assign({invalidate: 'never'}, options))
@getLastSelection().cursor.autoscroll() unless options?.autoscroll is false
@getLastSelection().cursor