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

Commit

Permalink
Return oldText in onDidChangeText change objects
Browse files Browse the repository at this point in the history
  • Loading branch information
hansonw committed Mar 14, 2017
1 parent 47a2793 commit 3dabe78
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions spec/text-buffer-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,8 @@ describe "TextBuffer", ->

expect(buffer.getText()).toBe 'abc\nyzf\nghi\njkl\nmno\npqr\nstu\nvwx\n'
expect(buffer.getChangesSinceCheckpoint(checkpoint)).toEqual [
{start: [1, 0], oldExtent: [0, 2], newExtent: [0, 2], newText: 'yz'},
{start: [5, 0], oldExtent: [0, 0], newExtent: [3, 0], newText: 'pqr\nstu\nvwx\n'}
{start: [1, 0], oldExtent: [0, 2], newExtent: [0, 2], oldText: 'de', newText: 'yz'},
{start: [5, 0], oldExtent: [0, 0], newExtent: [3, 0], oldText: '', newText: 'pqr\nstu\nvwx\n'}
]

it "returns an empty list of changes when no change has been made since the checkpoint", ->
Expand Down Expand Up @@ -2623,12 +2623,14 @@ describe "TextBuffer", ->
start: {row: 0, column: 0},
oldExtent: {row: 0, column: 0},
newExtent: {row: 0, column: 3},
oldText: "",
newText: "abc"
},
{
start: {row: 0, column: 0},
oldExtent: {row: 0, column: 1},
newExtent: {row: 0, column: 0},
oldText: "a",
newText: ""
}
])
Expand All @@ -2645,12 +2647,14 @@ describe "TextBuffer", ->
start: {row: 1, column: 0},
oldExtent: {row: 0, column: 0},
newExtent: {row: 0, column: 2},
oldText: "",
newText: "xy"
},
{
start: {row: 2, column: 3},
oldExtent: {row: 0, column: 0},
newExtent: {row: 0, column: 1},
oldText: "",
newText: "w"
}
])
Expand All @@ -2662,12 +2666,14 @@ describe "TextBuffer", ->
start: {row: 1, column: 0},
oldExtent: {row: 0, column: 2},
newExtent: {row: 0, column: 0},
oldText: "xy",
newText: ""
},
{
start: {row: 2, column: 3},
oldExtent: {row: 0, column: 1},
newExtent: {row: 0, column: 0},
oldText: "w",
newText: ""
}
])
Expand All @@ -2679,12 +2685,14 @@ describe "TextBuffer", ->
start: {row: 1, column: 0},
oldExtent: {row: 0, column: 0},
newExtent: {row: 0, column: 2},
oldText: "",
newText: "xy"
},
{
start: {row: 2, column: 3},
oldExtent: {row: 0, column: 0},
newExtent: {row: 0, column: 1},
oldText: "",
newText: "w"
}
])
Expand All @@ -2700,6 +2708,7 @@ describe "TextBuffer", ->
start: {row: 0, column: 0},
oldExtent: {row: 0, column: 0},
newExtent: {row: 0, column: 1},
oldText: "",
newText: "j"
}
])
Expand Down Expand Up @@ -2756,12 +2765,14 @@ describe "TextBuffer", ->
start: {row: 0, column: 0},
oldExtent: {row: 0, column: 0},
newExtent: {row: 0, column: 2},
oldText: '',
newText: 'ba'
},
{
start: {row: 1, column: 0},
oldExtent: {row: 0, column: 0},
newExtent: {row: 0, column: 1},
oldText: '',
newText: 'c'
}
]
Expand Down
1 change: 1 addition & 0 deletions src/helpers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports =
start: Point.fromObject(change.newStart)
oldExtent: traversal(change.oldEnd, change.oldStart)
newExtent: traversal(change.newEnd, change.newStart)
oldText: change.oldText
newText: change.newText
}

Expand Down

0 comments on commit 3dabe78

Please sign in to comment.