diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index 0d0be1949..252f0b739 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -205,6 +205,23 @@ describe('TextEditorComponent', () => { expect(component.getFirstVisibleRow()).toBe(editor.getScreenLineCount() + 1) }) + it('does not fire onDidChangeScrollTop listeners when assigning the same maximal value and the content height has fractional pixels (regression)', async () => { + const {component, element, editor} = buildComponent({autoHeight: false, autoWidth: false}) + await setEditorHeightInLines(component, 3) + + // Force a fractional content height with a block decoration + const item = document.createElement("div") + item.style.height = '10.6px' + editor.decorateMarker(editor.markBufferPosition([0, 0]), {type: "block", item}) + await component.getNextUpdatePromise() + + component.setScrollTop(Infinity) + element.onDidChangeScrollTop((newScrollTop) => { + throw new Error('Scroll top should not have changed') + }) + component.setScrollTop(component.getScrollTop()) + }) + it('gives the line number tiles an explicit width and height so their layout can be strictly contained', async () => { const {component, element, editor} = buildComponent({rowsPerTile: 3}) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index 67ed06f65..5e287fe73 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -2728,7 +2728,7 @@ class TextEditorComponent { } getMaxScrollTop () { - return Math.max(0, this.getScrollHeight() - this.getScrollContainerClientHeight()) + return Math.round(Math.max(0, this.getScrollHeight() - this.getScrollContainerClientHeight())) } getScrollBottom () { @@ -2756,7 +2756,7 @@ class TextEditorComponent { } getMaxScrollLeft () { - return Math.max(0, this.getScrollWidth() - this.getScrollContainerClientWidth()) + return Math.round(Math.max(0, this.getScrollWidth() - this.getScrollContainerClientWidth())) } getScrollRight () {