Wait for content width to update before autoscrolling horizontally

This commit is contained in:
Nathan Sobo 2017-03-15 12:08:38 -06:00 committed by Antonio Scandurra
parent 758466c9af
commit 5d82dcf87a
2 changed files with 14 additions and 1 deletions

View File

@ -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', () => {

View File

@ -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
}