Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #221 from atom/mb-ns-avoid-legacy-hunk-fields
Browse files Browse the repository at this point in the history
Update superstring
  • Loading branch information
Max Brunsfeld authored Mar 6, 2017
2 parents b5518f8 + e49c556 commit f0a7477
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"yargs": "^6.5.0"
},
"dependencies": {
"superstring": "1.1.0",
"superstring": "1.2.1",
"delegato": "^1.0.0",
"diff": "^2.2.1",
"emissary": "^1.0.0",
Expand Down
5 changes: 3 additions & 2 deletions src/helpers.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Point = require './point'
{traversal} = require './point-helpers'

MULTI_LINE_REGEX_REGEX = /\\s|\\r|\\n|\r|\n|^\[\^|[^\\]\[\^/

Expand Down Expand Up @@ -28,8 +29,8 @@ module.exports =
normalizePatchChanges: (changes) ->
changes.map (change) -> {
start: Point.fromObject(change.newStart)
oldExtent: Point.fromObject(change.oldExtent)
newExtent: Point.fromObject(change.newExtent)
oldExtent: traversal(change.oldEnd, change.oldStart)
newExtent: traversal(change.newEnd, change.newStart)
newText: change.newText
}

Expand Down
4 changes: 2 additions & 2 deletions src/marker-layer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class MarkerLayer
destroyMarker: (marker) ->
if @markersById.hasOwnProperty(marker.id)
delete @markersById[marker.id]
@index.delete(marker.id)
@index.remove(marker.id)
@markersWithChangeListeners.delete(marker)
@markersWithDestroyListeners.delete(marker)
@displayMarkerLayers.forEach (displayMarkerLayer) -> displayMarkerLayer.destroyMarker(marker.id)
Expand All @@ -359,7 +359,7 @@ class MarkerLayer
{start, end} = Range.fromObject(range)
start = @delegate.clipPosition(start)
end = @delegate.clipPosition(end)
@index.delete(id)
@index.remove(id)
@index.insert(id, start, end)

setMarkerIsExclusive: (id, exclusive) ->
Expand Down
14 changes: 12 additions & 2 deletions src/text-buffer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ MarkerLayer = require './marker-layer'
MatchIterator = require './match-iterator'
DisplayLayer = require './display-layer'
{spliceArray, newlineRegex, normalizePatchChanges, regexIsSingleLine} = require './helpers'
{traversal} = require './point-helpers'

class TransactionAbortedError extends Error
constructor: -> super
Expand Down Expand Up @@ -623,7 +624,14 @@ class TextBuffer

oldRange = @clipRange(range)
oldText = @getTextInRange(oldRange)
change = {newStart: oldRange.start, oldExtent: oldRange.getExtent(), oldText, newText, normalizeLineEndings}
change = {
oldStart: oldRange.start,
newStart: oldRange.start,
oldEnd: oldRange.end,
oldText,
newText,
normalizeLineEndings
}
@applyChange(change, undo isnt 'skip')

# Public: Insert text at the given position.
Expand Down Expand Up @@ -652,9 +660,10 @@ class TextBuffer

# Applies a change to the buffer based on its old range and new text.
applyChange: (change, pushToHistory = false) ->
{newStart, oldExtent, oldText, newText, normalizeLineEndings} = change
{newStart, oldStart, oldEnd, oldText, newText, normalizeLineEndings} = change
@cachedText = null

oldExtent = traversal(oldEnd, oldStart)
start = Point.fromObject(newStart)
oldRange = Range(start, start.traverse(oldExtent))
oldRange.freeze()
Expand Down Expand Up @@ -694,6 +703,7 @@ class TextBuffer
newRange.freeze()

if pushToHistory
change.oldExtent ?= oldExtent
change.newExtent ?= newExtent
@history?.pushChange(change)

Expand Down

0 comments on commit f0a7477

Please sign in to comment.