mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Fix spurious selections marker layer update to avoid extra render
This commit is contained in:
parent
be7f4a5ffd
commit
b362f746f8
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user