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

Commit

Permalink
Fix fromObject when object is undefined
Browse files Browse the repository at this point in the history
In [email protected] there is an unrecoverable error occurring when parameter `object` is undefined.

```
Uncaught (in promise) TypeError: Cannot read property 'start' of undefined
    at Function.module.exports.Range.fromObject (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/range.js:33:37)
    at Function.module.exports.MarkerLayer.deserializeSnapshot (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/marker-layer.js:39:57)
    at History.module.exports.History.deserializeStack (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/history.js:427:60)
    at History.module.exports.History.deserialize (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/history.js:361:35)
    at /Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:264:30
```
  • Loading branch information
bstream authored and Andreas Broström committed Sep 18, 2017
1 parent 4b6cbcd commit ba9481a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions spec/range-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ describe "Range", ->
beforeEach ->
jasmine.addCustomEqualityTester(require("underscore-plus").isEqual)

describe "::fromObject() when object is falsy", ->
it "should not throw", ->
expect(-> Range.fromObject(null)).not.toThrow()
it "should get default values", ->
expect(Range.fromObject(null).toString()).toBe "[(0, 0) - (0, 0)]"

describe "::intersectsWith(other, [exclusive])", ->
intersectsWith = (range1, range2, exclusive) ->
range1 = Range.fromObject(range1)
Expand Down
2 changes: 1 addition & 1 deletion src/range.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Range
# that are already ranges.˚
#
# Returns: A {Range} based on the given object.
@fromObject: (object, copy) ->
@fromObject: (object = {}, copy) ->
if Array.isArray(object)
new this(object[0], object[1])
else if object instanceof this
Expand Down

0 comments on commit ba9481a

Please sign in to comment.