From f6688b6d712142d17d6cd0c0504973e17408f703 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 3 Dec 2015 15:24:55 +0100 Subject: [PATCH] Don't use babel when not needed --- src/block-decorations-presenter.js | 25 ++++++++++++------------- src/linear-line-top-index.js | 5 +++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/block-decorations-presenter.js b/src/block-decorations-presenter.js index f1a05da85..9964f3eb9 100644 --- a/src/block-decorations-presenter.js +++ b/src/block-decorations-presenter.js @@ -1,13 +1,13 @@ -/** @babel */ +'use strict' -const {CompositeDisposable, Emitter} = require('event-kit') +const EventKit = require('event-kit') module.exports = class BlockDecorationsPresenter { constructor (model, lineTopIndex) { this.model = model - this.disposables = new CompositeDisposable() - this.emitter = new Emitter() + this.disposables = new EventKit.CompositeDisposable() + this.emitter = new EventKit.Emitter() this.firstUpdate = true this.lineTopIndex = lineTopIndex this.blocksByDecoration = new Map() @@ -33,13 +33,12 @@ class BlockDecorationsPresenter { observeModel () { this.lineTopIndex.setMaxRow(this.model.getScreenLineCount()) this.lineTopIndex.setDefaultLineHeight(this.model.getLineHeightInPixels()) - this.disposables.add(this.model.onDidAddDecoration((decoration) => { - this.observeDecoration(decoration) - })) - this.disposables.add(this.model.onDidChange(({start, end, screenDelta}) => { - let oldExtent = end - start - let newExtent = Math.max(0, end - start + screenDelta) - this.lineTopIndex.splice(start, oldExtent, newExtent) + + this.disposables.add(this.model.onDidAddDecoration(this.observeDecoration.bind(this))) + this.disposables.add(this.model.onDidChange((changeEvent) => { + let oldExtent = changeEvent.end - changeEvent.start + let newExtent = Math.max(0, changeEvent.end - changeEvent.start + changeEvent.screenDelta) + this.lineTopIndex.splice(changeEvent.start, oldExtent, newExtent) })) } @@ -125,8 +124,8 @@ class BlockDecorationsPresenter { this.emitter.emit('did-update-state') } - didMoveDecoration (decoration, {textChanged}) { - if (textChanged) { + didMoveDecoration (decoration, markerEvent) { + if (markerEvent.textChanged) { // No need to move blocks because of a text change, because we already splice on buffer change. return } diff --git a/src/linear-line-top-index.js b/src/linear-line-top-index.js index a930b4a38..3fe501ec9 100644 --- a/src/linear-line-top-index.js +++ b/src/linear-line-top-index.js @@ -1,4 +1,4 @@ -/** @babel */ +'use strict' module.exports = class LineTopIndex { @@ -81,7 +81,8 @@ class LineTopIndex { return this.topPixelPositionForRow(row + 1) - this.defaultLineHeight } - rowForTopPixelPosition (top, roundingStrategy='floor') { + rowForTopPixelPosition (top, strategy) { + const roundingStrategy = strategy || 'floor' let blocksHeight = 0 let lastRow = 0 let lastTop = 0