From 8cb4593c79d693fa72067047b89542f49860833b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Brostr=C3=B6m?= Date: Mon, 18 Sep 2017 10:29:24 +0200 Subject: [PATCH] Fix fromObject when `object` is undefined In atom@1.20.0 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 ``` --- src/range.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/range.coffee b/src/range.coffee index f7ed5d72ae..246e90f57a 100644 --- a/src/range.coffee +++ b/src/range.coffee @@ -45,7 +45,7 @@ class Range else if object instanceof this if copy then object.copy() else object else - new this(object.start, object.end) + if object != null then new this(object.start, object.end) else new this() # Returns a range based on an optional starting point and the given text. If # no starting point is given it will be assumed to be [0, 0].