Skip to content

Commit 46ba9bb

Browse files
authored
Merge pull request #740 from atom-minimap/use-template-strings
2 parents 152e168 + d7ba069 commit 46ba9bb

File tree

6 files changed

+102
-105
lines changed

6 files changed

+102
-105
lines changed

lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ export function standAloneMinimapForEditor (textEditor) {
312312
if (!textEditor) { return }
313313

314314
return new Minimap({
315-
textEditor: textEditor,
315+
textEditor,
316316
standAlone: true
317317
})
318318
}

lib/minimap-element.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -634,13 +634,13 @@ class MinimapElement {
634634
})
635635

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

640640
if (this.displayMinimapOnLeft) {
641-
this.quickSettingsElement.style.left = (right) + 'px'
641+
this.quickSettingsElement.style.left = `${right}px`
642642
} else {
643-
this.quickSettingsElement.style.left = (left - this.quickSettingsElement.clientWidth) + 'px'
643+
this.quickSettingsElement.style.left = `${left - this.quickSettingsElement.clientWidth}px`
644644
}
645645
}
646646
}
@@ -830,43 +830,43 @@ class MinimapElement {
830830
const visibleWidth = width + visibleAreaLeft
831831

832832
if (this.adjustToSoftWrap && this.flexBasis) {
833-
this.style.flexBasis = this.flexBasis + 'px'
834-
this.style.width = this.flexBasis + 'px'
833+
this.style.flexBasis = `${this.flexBasis}px`
834+
this.style.width = `${this.flexBasis}px`
835835
} else {
836836
this.style.flexBasis = null
837837
this.style.width = null
838838
}
839839

840840
if (SPEC_MODE) {
841841
applyStyles(this.visibleArea, {
842-
width: Math.round(visibleWidth) + 'px',
843-
height: Math.round(minimap.getTextEditorScaledHeight()) + 'px',
844-
top: Math.round(visibleAreaTop) + 'px',
845-
'border-left-width': Math.round(visibleAreaLeft) + 'px'
842+
width: `${Math.round(visibleWidth)}px`,
843+
height: `${Math.round(minimap.getTextEditorScaledHeight())}px`,
844+
top: `${Math.round(visibleAreaTop)}px`,
845+
'border-left-width': `${Math.round(visibleAreaLeft)}px`
846846
})
847847
} else {
848848
applyStyles(this.visibleArea, {
849-
width: Math.round(visibleWidth) + 'px',
850-
height: Math.round(minimap.getTextEditorScaledHeight()) + 'px',
849+
width: `${Math.round(visibleWidth)}px`,
850+
height: `${Math.round(minimap.getTextEditorScaledHeight())}px`,
851851
transform: makeTranslate(0, visibleAreaTop, this.useHardwareAcceleration),
852-
'border-left-width': Math.round(visibleAreaLeft) + 'px'
852+
'border-left-width': `${Math.round(visibleAreaLeft)}px`
853853
})
854854
}
855855

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

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

860860
if (this.smoothScrolling) {
861861
if (SPEC_MODE) {
862-
applyStyles(this.backLayer.canvas, { top: canvasTop + 'px' })
863-
applyStyles(this.tokensLayer.canvas, { top: canvasTop + 'px' })
864-
applyStyles(this.frontLayer.canvas, { top: canvasTop + 'px' })
862+
applyStyles(this.backLayer.canvas, { top: `${canvasTop}px` })
863+
applyStyles(this.tokensLayer.canvas, { top: `${canvasTop}px` })
864+
applyStyles(this.frontLayer.canvas, { top: `${canvasTop}px` })
865865
} else {
866866
let canvasTransform = makeTranslate(0, canvasTop, this.useHardwareAcceleration)
867867
if (devicePixelRatio !== 1) {
868868
const scale = 1 / devicePixelRatio
869-
canvasTransform += ' ' + makeScale(scale, scale, this.useHardwareAcceleration)
869+
canvasTransform += ` ${makeScale(scale, scale, this.useHardwareAcceleration)}`
870870
}
871871
applyStyles(this.backLayer.canvas, { transform: canvasTransform })
872872
applyStyles(this.tokensLayer.canvas, { transform: canvasTransform })
@@ -891,12 +891,12 @@ class MinimapElement {
891891

892892
if (SPEC_MODE) {
893893
applyStyles(this.scrollIndicator, {
894-
height: indicatorHeight + 'px',
895-
top: indicatorScroll + 'px'
894+
height: `${indicatorHeight}px`,
895+
top: `${indicatorScroll}px`
896896
})
897897
} else {
898898
applyStyles(this.scrollIndicator, {
899-
height: indicatorHeight + 'px',
899+
height: `${indicatorHeight}px`,
900900
transform: makeTranslate(0, indicatorScroll, this.useHardwareAcceleration)
901901
})
902902
}
@@ -1109,13 +1109,13 @@ class MinimapElement {
11091109
this.minimap.setTextEditorScrollTop(now, true)
11101110
this.minimap.setScrollTop(minimapFrom + (minimapTo - minimapFrom) * t)
11111111
}
1112-
animate({ from: from, to: to, duration: duration, step: step })
1112+
animate({ from, to, duration, step })
11131113
} else {
11141114
step = (now) => {
11151115
if (this.minimap === null) return // TODO why this happens in the tests?
11161116
this.minimap.setTextEditorScrollTop(now)
11171117
}
1118-
animate({ from: from, to: to, duration: duration, step: step })
1118+
animate({ from, to, duration, step })
11191119
}
11201120
} else {
11211121
this.minimap.setTextEditorScrollTop(textEditorScrollTop)

lib/mixins/canvas-drawer.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,11 @@ export default class CanvasDrawer extends Mixin {
336336
const { width: canvasWidth, height: canvasHeight } = this.tokensLayer.getSize()
337337
const renderData = {
338338
context: this.backLayer.context,
339-
canvasWidth: canvasWidth,
340-
canvasHeight: canvasHeight,
341-
lineHeight: lineHeight,
342-
charWidth: charWidth,
343-
charHeight: charHeight,
339+
canvasWidth,
340+
canvasHeight,
341+
lineHeight,
342+
charWidth,
343+
charHeight,
344344
orders: Main.getPluginsOrder()
345345
}
346346

@@ -382,11 +382,11 @@ export default class CanvasDrawer extends Mixin {
382382
const { width: canvasWidth, height: canvasHeight } = this.tokensLayer.getSize()
383383
const renderData = {
384384
context: this.frontLayer.context,
385-
canvasWidth: canvasWidth,
386-
canvasHeight: canvasHeight,
387-
lineHeight: lineHeight,
388-
charWidth: charWidth,
389-
charHeight: charHeight,
385+
canvasWidth,
386+
canvasHeight,
387+
lineHeight,
388+
charWidth,
389+
charHeight,
390390
orders: Main.getPluginsOrder()
391391
}
392392

lib/mixins/decoration-management.js

Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ export default class DecorationManagement {
233233

234234
const decorations = this.decorationsById.values()
235235
for (const decoration of decorations) {
236-
237236
const range = decoration.marker.getScreenRange()
238237
const type = decoration.getProperties().type
239238

@@ -340,57 +339,57 @@ export default class DecorationManagement {
340339

341340
if (!this.decorationMarkerDestroyedSubscriptions.has(id)) {
342341
this.decorationMarkerDestroyedSubscriptions.set(id,
343-
marker.onDidDestroy(() => {
344-
this.removeAllDecorationsForMarker(marker)
345-
}))
342+
marker.onDidDestroy(() => {
343+
this.removeAllDecorationsForMarker(marker)
344+
}))
346345
}
347346

348347
if (!this.decorationMarkerChangedSubscriptions.has(id)) {
349348
this.decorationMarkerChangedSubscriptions.set(id,
350-
marker.onDidChange((event) => {
351-
const decorations = this.decorationsByMarkerId.get(id)
352-
const screenRange = marker.getScreenRange()
353-
354-
this.invalidateDecorationForScreenRowsCache()
355-
356-
if (decorations !== undefined) {
357-
for (let i = 0, len = decorations.length; i < len; i++) {
358-
const decoration = decorations[i]
359-
this.emitter.emit('did-change-decoration', {
360-
marker: marker,
361-
decoration: decoration,
362-
event: event
363-
})
364-
this.emitDecorationChanges(decoration.type, decoration)
365-
366-
decoration.screenRange = screenRange
349+
marker.onDidChange((event) => {
350+
const decorations = this.decorationsByMarkerId.get(id)
351+
const screenRange = marker.getScreenRange()
352+
353+
this.invalidateDecorationForScreenRowsCache()
354+
355+
if (decorations !== undefined) {
356+
for (let i = 0, len = decorations.length; i < len; i++) {
357+
const decoration = decorations[i]
358+
this.emitter.emit('did-change-decoration', {
359+
marker,
360+
decoration,
361+
event
362+
})
363+
this.emitDecorationChanges(decoration.type, decoration)
364+
365+
decoration.screenRange = screenRange
366+
}
367367
}
368-
}
369-
let oldStart = event.oldTailScreenPosition
370-
let oldEnd = event.oldHeadScreenPosition
371-
let newStart = event.newTailScreenPosition
372-
let newEnd = event.newHeadScreenPosition
373-
374-
if (oldStart.row > oldEnd.row) {
375-
[oldStart, oldEnd] = [oldEnd, oldStart]
376-
}
377-
if (newStart.row > newEnd.row) {
378-
[newStart, newEnd] = [newEnd, newStart]
379-
}
380-
381-
const rangesDiffs = this.computeRangesDiffs(
382-
oldStart, oldEnd,
383-
newStart, newEnd
384-
)
385-
386-
for (let i = 0, len = rangesDiffs.length; i < len; i++) {
387-
const [start, end] = rangesDiffs[i]
388-
this.emitRangeChanges(type, {
389-
start: start,
390-
end: end
391-
}, 0)
392-
}
393-
}))
368+
let oldStart = event.oldTailScreenPosition
369+
let oldEnd = event.oldHeadScreenPosition
370+
let newStart = event.newTailScreenPosition
371+
let newEnd = event.newHeadScreenPosition
372+
373+
if (oldStart.row > oldEnd.row) {
374+
[oldStart, oldEnd] = [oldEnd, oldStart]
375+
}
376+
if (newStart.row > newEnd.row) {
377+
[newStart, newEnd] = [newEnd, newStart]
378+
}
379+
380+
const rangesDiffs = this.computeRangesDiffs(
381+
oldStart, oldEnd,
382+
newStart, newEnd
383+
)
384+
385+
for (let i = 0, len = rangesDiffs.length; i < len; i++) {
386+
const [start, end] = rangesDiffs[i]
387+
this.emitRangeChanges(type, {
388+
start,
389+
end
390+
}, 0)
391+
}
392+
}))
394393
}
395394

396395
const decoration = new Decoration(marker, this, decorationParams)
@@ -404,20 +403,20 @@ export default class DecorationManagement {
404403

405404
if (!this.decorationUpdatedSubscriptions.has(decoration.id)) {
406405
this.decorationUpdatedSubscriptions.set(decoration.id,
407-
decoration.onDidChangeProperties((event) => {
408-
this.emitDecorationChanges(type, decoration)
409-
}))
406+
decoration.onDidChangeProperties((event) => {
407+
this.emitDecorationChanges(type, decoration)
408+
}))
410409
}
411410

412411
this.decorationDestroyedSubscriptions.set(decoration.id,
413-
decoration.onDidDestroy(() => {
414-
this.removeDecoration(decoration)
415-
}))
412+
decoration.onDidDestroy(() => {
413+
this.removeDecoration(decoration)
414+
}))
416415

417416
this.emitDecorationChanges(type, decoration)
418417
this.emitter.emit('did-add-decoration', {
419-
marker: marker,
420-
decoration: decoration
418+
marker,
419+
decoration
421420
})
422421

423422
return decoration
@@ -504,8 +503,8 @@ export default class DecorationManagement {
504503
const changeEvent = {
505504
start: startScreenRow,
506505
end: endScreenRow,
507-
screenDelta: screenDelta,
508-
type: type
506+
screenDelta,
507+
type
509508
}
510509

511510
this.emitter.emit('did-change-decoration-range', changeEvent)
@@ -545,8 +544,8 @@ export default class DecorationManagement {
545544
decorations.splice(index, 1)
546545

547546
this.emitter.emit('did-remove-decoration', {
548-
marker: marker,
549-
decoration: decoration
547+
marker,
548+
decoration
550549
})
551550

552551
if (decorations.length === 0) {
@@ -575,8 +574,8 @@ export default class DecorationManagement {
575574
this.emitDecorationChanges(decoration.getProperties().type, decoration)
576575
}
577576
this.emitter.emit('did-remove-decoration', {
578-
marker: marker,
579-
decoration: decoration
577+
marker,
578+
decoration
580579
})
581580
}
582581

lib/plugin-management.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function registerPlugin (name, plugin) {
5959
plugins[name] = plugin
6060
pluginsSubscriptions[name] = new CompositeDisposable()
6161

62-
const event = { name: name, plugin: plugin }
62+
const event = { name, plugin }
6363
emitter.emit('did-add-plugin', event)
6464

6565
if (atom.config.get('minimap.displayPluginsControls')) {
@@ -85,7 +85,7 @@ export function unregisterPlugin (name) {
8585

8686
delete plugins[name]
8787

88-
const event = { name: name, plugin: plugin }
88+
const event = { name, plugin }
8989
emitter.emit('did-remove-plugin', event)
9090
}
9191

@@ -120,7 +120,7 @@ export function togglePluginActivation (name, boolean) {
120120
export function deactivateAllPlugins () {
121121
for (const [name, plugin] of eachPlugin()) {
122122
plugin.deactivatePlugin()
123-
emitter.emit('did-deactivate-plugin', { name: name, plugin: plugin })
123+
emitter.emit('did-deactivate-plugin', { name, plugin })
124124
}
125125
}
126126

@@ -165,14 +165,14 @@ function updatesPluginActivationState (name) {
165165
}
166166

167167
export function activatePlugin (name, plugin) {
168-
const event = { name: name, plugin: plugin }
168+
const event = { name, plugin }
169169

170170
plugin.activatePlugin()
171171
emitter.emit('did-activate-plugin', event)
172172
}
173173

174174
export function deactivatePlugin (name, plugin) {
175-
const event = { name: name, plugin: plugin }
175+
const event = { name, plugin }
176176

177177
plugin.deactivatePlugin()
178178
emitter.emit('did-deactivate-plugin', event)
@@ -226,7 +226,7 @@ function registerPluginControls (name, plugin) {
226226

227227
pluginsSubscriptions[name].add(atom.config.observe(orderSettingsKey, (order) => {
228228
updatePluginsOrderMap(name)
229-
const event = { name: name, plugin: plugin, order: order }
229+
const event = { name, plugin, order }
230230
emitter.emit('did-change-plugin-order', event)
231231
}))
232232

0 commit comments

Comments
 (0)