   setBlockAttribute: (attributeName, value) ->
     return unless locationRange = @getLocationRange()
     @notifyDelegateOfIntentionToSetLocationRange()
-    [startPosition, endPosition] = @document.rangeFromLocationRange(locationRange)
-
+    range = @document.rangeFromLocationRange(locationRange)
     @document.applyBlockAttributeAtLocationRange(attributeName, value, locationRange)
-
-    {start} = @document.locationRangeFromPosition(startPosition)
-    {end} = @document.locationRangeFromPosition(endPosition)
-    @setLocationRange(start, end)
+    @setRange(range)
 
   removeCurrentAttribute: (attributeName) ->
     if Trix.blockAttributes[attributeName]

    @setPosition(@getPosition() + distance)

  expandLocationRangeInDirection: (direction) ->
    locationRange = @getLocationRange()
    [start, end] = @document.rangeFromLocationRange(locationRange)
    if direction is "backward" then start-- else end++
    @setLocationRange(@document.locationRangeFromRange([start, end]))

  expandSelectionInDirection: (direction) ->
    if @shouldExpandInDirectionUsingLocationRange(direction)


  # Location range and selection

  getRange: ->
    locationRange = @getLocationRange()
    @document.rangeFromLocationRange(locationRange)

  setRange: (range) ->
    locationRange = @document.locationRangeFromRange(range)
    @setLocationRange(locationRange)

  getPosition: ->
    @getRange()[0]

  setPosition: (position) ->
    locationRange = @document.locationRangeFromPosition(position)
