Skip to content

Commit

Permalink
fix: use strings interpolation instead of +
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Dec 31, 2020
1 parent 152e168 commit 012dd00
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
40 changes: 20 additions & 20 deletions lib/minimap-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,13 +634,13 @@ class MinimapElement {
})

const { top, left, right } = this.getFrontCanvas().getBoundingClientRect()
this.quickSettingsElement.style.top = top + 'px'
this.quickSettingsElement.style.top = `${top}px`
this.quickSettingsElement.attach()

if (this.displayMinimapOnLeft) {
this.quickSettingsElement.style.left = (right) + 'px'
this.quickSettingsElement.style.left = `${right}px`
} else {
this.quickSettingsElement.style.left = (left - this.quickSettingsElement.clientWidth) + 'px'
this.quickSettingsElement.style.left = `${left - this.quickSettingsElement.clientWidth}px`
}
}
}
Expand Down Expand Up @@ -830,43 +830,43 @@ class MinimapElement {
const visibleWidth = width + visibleAreaLeft

if (this.adjustToSoftWrap && this.flexBasis) {
this.style.flexBasis = this.flexBasis + 'px'
this.style.width = this.flexBasis + 'px'
this.style.flexBasis = `${this.flexBasis}px`
this.style.width = `${this.flexBasis}px`
} else {
this.style.flexBasis = null
this.style.width = null
}

if (SPEC_MODE) {
applyStyles(this.visibleArea, {
width: Math.round(visibleWidth) + 'px',
height: Math.round(minimap.getTextEditorScaledHeight()) + 'px',
top: Math.round(visibleAreaTop) + 'px',
'border-left-width': Math.round(visibleAreaLeft) + 'px'
width: `${Math.round(visibleWidth)}px`,
height: `${Math.round(minimap.getTextEditorScaledHeight())}px`,
top: `${Math.round(visibleAreaTop)}px`,
'border-left-width': `${Math.round(visibleAreaLeft)}px`
})
} else {
applyStyles(this.visibleArea, {
width: Math.round(visibleWidth) + 'px',
height: Math.round(minimap.getTextEditorScaledHeight()) + 'px',
width: `${Math.round(visibleWidth)}px`,
height: `${Math.round(minimap.getTextEditorScaledHeight())}px`,
transform: makeTranslate(0, visibleAreaTop, this.useHardwareAcceleration),
'border-left-width': Math.round(visibleAreaLeft) + 'px'
'border-left-width': `${Math.round(visibleAreaLeft)}px`
})
}

applyStyles(this.controls, { width: Math.round(width) + 'px' })
applyStyles(this.controls, { width: `${Math.round(width)}px` })

const canvasTop = minimap.getFirstVisibleScreenRow() * minimap.getLineHeight() - minimap.getScrollTop()

if (this.smoothScrolling) {
if (SPEC_MODE) {
applyStyles(this.backLayer.canvas, { top: canvasTop + 'px' })
applyStyles(this.tokensLayer.canvas, { top: canvasTop + 'px' })
applyStyles(this.frontLayer.canvas, { top: canvasTop + 'px' })
applyStyles(this.backLayer.canvas, { top: `${canvasTop}px` })
applyStyles(this.tokensLayer.canvas, { top: `${canvasTop}px` })
applyStyles(this.frontLayer.canvas, { top: `${canvasTop}px` })
} else {
let canvasTransform = makeTranslate(0, canvasTop, this.useHardwareAcceleration)
if (devicePixelRatio !== 1) {
const scale = 1 / devicePixelRatio
canvasTransform += ' ' + makeScale(scale, scale, this.useHardwareAcceleration)
canvasTransform += ` ${makeScale(scale, scale, this.useHardwareAcceleration)}`
}
applyStyles(this.backLayer.canvas, { transform: canvasTransform })
applyStyles(this.tokensLayer.canvas, { transform: canvasTransform })
Expand All @@ -891,12 +891,12 @@ class MinimapElement {

if (SPEC_MODE) {
applyStyles(this.scrollIndicator, {
height: indicatorHeight + 'px',
top: indicatorScroll + 'px'
height: `${indicatorHeight}px`,
top: `${indicatorScroll}px`
})
} else {
applyStyles(this.scrollIndicator, {
height: indicatorHeight + 'px',
height: `${indicatorHeight}px`,
transform: makeTranslate(0, indicatorScroll, this.useHardwareAcceleration)
})
}
Expand Down
8 changes: 3 additions & 5 deletions spec/minimap-element-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,7 @@ describe('MinimapElement', () => {
expect(editorElement.getScrollTop()).toBeNear(expectedScroll, 3)
})

describe('dragging the visible area with middle mouse button ' +
'after scrolling to the arbitrary location', () => {
describe('dragging the visible area with middle mouse button after scrolling to the arbitrary location', () => {
let [originalTop] = []

beforeEach(() => {
Expand All @@ -769,8 +768,7 @@ describe('MinimapElement', () => {
minimapElement.endDrag()
})

it('scrolls the editor so that the visible area was moved down ' +
'by 40 pixels from the arbitrary location', () => {
it('scrolls the editor so that the visible area was moved down by 40 pixels from the arbitrary location', () => {
const { top } = visibleArea.getBoundingClientRect()
expect(top).toBeCloseTo(originalTop + 40, -1)
})
Expand Down Expand Up @@ -1487,7 +1485,7 @@ describe('MinimapElement', () => {

it('adjusts the width of the minimap', () => {
expect(minimapElement.offsetWidth).toBeCloseTo(16384 * 2)
expect(minimapElement.style.width).toEqual(16384 * 2 + 'px')
expect(minimapElement.style.width).toEqual(`${16384 * 2}px`)
})
})
})
Expand Down

0 comments on commit 012dd00

Please sign in to comment.