diff --git a/src/block-decorations-presenter.js b/src/block-decorations-presenter.js index 373444c45..c5697e7d4 100644 --- a/src/block-decorations-presenter.js +++ b/src/block-decorations-presenter.js @@ -7,8 +7,8 @@ class BlockDecorationsPresenter { constructor (model) { this.model = model this.emitter = new Emitter() - this.blockDecorationsDimensionsById = new Map - this.blockDecorationsByScreenRow = new Map + this.dimensionsByDecorationId = new Map + this.decorationsByScreenRow = new Map this.heightsByScreenRow = new Map } @@ -18,58 +18,58 @@ class BlockDecorationsPresenter { update () { this.heightsByScreenRow.clear() - this.blockDecorationsByScreenRow.clear() - let blockDecorations = new Map + this.decorationsByScreenRow.clear() + let decorations = new Map // TODO: move into DisplayBuffer for (let decoration of this.model.getDecorations({type: "block"})) { - blockDecorations.set(decoration.id, decoration) + decorations.set(decoration.id, decoration) } - for (let [decorationId] of this.blockDecorationsDimensionsById) { - if (!blockDecorations.has(decorationId)) { - this.blockDecorationsDimensionsById.delete(decorationId) + for (let [decorationId] of this.dimensionsByDecorationId) { + if (!decorations.has(decorationId)) { + this.dimensionsByDecorationId.delete(decorationId) } } - for (let [decorationId, decoration] of blockDecorations) { + for (let [decorationId, decoration] of decorations) { let screenRow = decoration.getMarker().getHeadScreenPosition().row - this.addBlockDecorationToScreenRow(screenRow, decoration) - if (this.hasMeasuredBlockDecoration(decoration)) { + this.addDecorationToScreenRow(screenRow, decoration) + if (this.hasMeasurementsForDecoration(decoration)) { this.addHeightToScreenRow( screenRow, - this.blockDecorationsDimensionsById.get(decorationId).height + this.dimensionsByDecorationId.get(decorationId).height ) } } } - setBlockDecorationDimensions (decoration, width, height) { - this.blockDecorationsDimensionsById.set(decoration.id, {width, height}) + setDimensionsForDecoration (decoration, width, height) { + this.dimensionsByDecorationId.set(decoration.id, {width, height}) this.emitter.emit('did-update-state') } - blockDecorationsHeightForScreenRow (screenRow) { + heightForScreenRow (screenRow) { return Number(this.heightsByScreenRow.get(screenRow)) || 0 } addHeightToScreenRow (screenRow, height) { - let previousHeight = this.blockDecorationsHeightForScreenRow(screenRow) + let previousHeight = this.heightForScreenRow(screenRow) let newHeight = previousHeight + height this.heightsByScreenRow.set(screenRow, newHeight) } - addBlockDecorationToScreenRow (screenRow, decoration) { - let decorations = this.blockDecorationsForScreenRow(screenRow) || [] + addDecorationToScreenRow (screenRow, decoration) { + let decorations = this.getDecorationsByScreenRow(screenRow) || [] decorations.push(decoration) - this.blockDecorationsByScreenRow.set(screenRow, decorations) + this.decorationsByScreenRow.set(screenRow, decorations) } - blockDecorationsForScreenRow (screenRow) { - return this.blockDecorationsByScreenRow.get(screenRow) + getDecorationsByScreenRow (screenRow) { + return this.decorationsByScreenRow.get(screenRow) } - hasMeasuredBlockDecoration (decoration) { - return this.blockDecorationsDimensionsById.has(decoration.id) + hasMeasurementsForDecoration (decoration) { + return this.dimensionsByDecorationId.has(decoration.id) } } diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 0e7a2c56d..153a78dbf 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -506,7 +506,7 @@ class TextEditorPresenter lineState = tileState.lines[line.id] lineState.screenRow = screenRow lineState.decorationClasses = @lineDecorationClassesForRow(screenRow) - lineState.blockDecorations = this.blockDecorationsPresenter.blockDecorationsForScreenRow(screenRow) + lineState.blockDecorations = this.blockDecorationsPresenter.getDecorationsByScreenRow(screenRow) else tileState.lines[line.id] = screenRow: screenRow @@ -523,7 +523,7 @@ class TextEditorPresenter tabLength: line.tabLength fold: line.fold decorationClasses: @lineDecorationClassesForRow(screenRow) - blockDecorations: this.blockDecorationsPresenter.blockDecorationsForScreenRow(screenRow) + blockDecorations: this.blockDecorationsPresenter.getDecorationsByScreenRow(screenRow) for id, line of tileState.lines delete tileState.lines[id] unless visibleLineIds.hasOwnProperty(id) @@ -722,7 +722,7 @@ class TextEditorPresenter line = @model.tokenizedLineForScreenRow(screenRow) decorationClasses = @lineNumberDecorationClassesForRow(screenRow) foldable = @model.isFoldableAtScreenRow(screenRow) - blockDecorationsHeight = @blockDecorationsPresenter.blockDecorationsHeightForScreenRow(screenRow) + blockDecorationsHeight = @blockDecorationsPresenter.heightForScreenRow(screenRow) tileState.lineNumbers[line.id] = {screenRow, bufferRow, softWrapped, decorationClasses, foldable, blockDecorationsHeight} visibleLineNumberIds[line.id] = true @@ -733,7 +733,7 @@ class TextEditorPresenter return getScreenRowHeight: (screenRow) -> - @lineHeight + @blockDecorationsPresenter.blockDecorationsHeightForScreenRow(screenRow) + @lineHeight + @blockDecorationsPresenter.heightForScreenRow(screenRow) getScreenRowsHeight: (startRow, endRow) -> height = 0 @@ -1419,7 +1419,7 @@ class TextEditorPresenter @emitDidUpdateState() setBlockDecorationDimensions: (decoration, width, height) -> - @blockDecorationsPresenter.setBlockDecorationDimensions(arguments...) + @blockDecorationsPresenter.setDimensionsForDecoration(arguments...) observeCursor: (cursor) -> didChangePositionDisposable = cursor.onDidChangePosition =>