Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Round return values of getMaxScrollTop, getScrollHeight #15345

Merged
merged 1 commit into from Aug 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions spec/text-editor-component-spec.js
Expand Up @@ -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})

Expand Down
4 changes: 2 additions & 2 deletions src/text-editor-component.js
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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 () {
Expand Down