mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Wait for content width to update before autoscrolling horizontally
This commit is contained in:
committed by
Antonio Scandurra
parent
758466c9af
commit
5d82dcf87a
@@ -391,6 +391,19 @@ describe('TextEditorComponent', () => {
|
||||
)
|
||||
expect(scroller.scrollLeft).toBe(expectedScrollLeft)
|
||||
})
|
||||
|
||||
it('correctly autoscrolls after inserting a line that exceeds the current content width', async () => {
|
||||
const {component, element, editor} = buildComponent()
|
||||
const {scroller} = component.refs
|
||||
element.style.width = component.getScrollWidth() + 'px'
|
||||
await component.getNextUpdatePromise()
|
||||
|
||||
editor.setCursorScreenPosition([0, Infinity])
|
||||
editor.insertText('x'.repeat(100))
|
||||
await component.getNextUpdatePromise()
|
||||
|
||||
expect(scroller.scrollLeft).toBe(component.getScrollWidth() - scroller.clientWidth)
|
||||
})
|
||||
})
|
||||
|
||||
describe('line and line number decorations', () => {
|
||||
|
||||
@@ -107,11 +107,11 @@ class TextEditorComponent {
|
||||
|
||||
this.measureHorizontalPositions()
|
||||
if (longestLineToMeasure) this.measureLongestLineWidth(longestLineToMeasure)
|
||||
if (this.pendingAutoscroll) this.finalizeAutoscroll()
|
||||
this.updateAbsolutePositionedDecorations()
|
||||
|
||||
etch.updateSync(this)
|
||||
|
||||
if (this.pendingAutoscroll) this.finalizeAutoscroll()
|
||||
this.currentFrameLineNumberGutterProps = null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user