Fix editor element tests on Windows

This commit is contained in:
Antonio Scandurra 2017-05-12 16:51:05 +02:00
parent 5848e9b2d0
commit 96533998e2
2 changed files with 11 additions and 2 deletions

View File

@ -349,7 +349,16 @@ describe('TextEditorElement', () => {
await element.getNextUpdatePromise()
expect(element.getVisibleRowRange()).toEqual([4, 11])
expect(element.pixelRectForScreenRange([[2, 3], [13, 11]])).toEqual({top: 34, left: 22, height: 204, width: 57})
const top = 2 * editor.getLineHeightInPixels()
const bottom = 13 * editor.getLineHeightInPixels()
const left = Math.round(3 * editor.getDefaultCharWidth())
const right = Math.round(11 * editor.getDefaultCharWidth())
expect(element.pixelRectForScreenRange([[2, 3], [13, 11]])).toEqual({
top,
left,
height: bottom + editor.getLineHeightInPixels() - top,
width: right - left
})
})
})

View File

@ -2667,7 +2667,7 @@ class TextEditorComponent {
getScrollLeftColumn () {
if (this.hasInitialMeasurements && this.getLongestLineWidth() != null) {
return Math.floor(this.getScrollLeft() / this.getBaseCharacterWidth())
return Math.round(this.getScrollLeft() / this.getBaseCharacterWidth())
} else {
return this.pendingScrollLeftColumn || 0
}