mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 18:24:09 +03:00
Use _.isArray to determine whether a value is Array.
When passing arrays between child processes with node's IPC machanism, `instance of Array` will return false for the deserialized array, we should use the reiable way of detecting Array provided by underscore. Read this for more: http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/ This bug was found when moving spell-check to use ProcessTask, and the wrong Range object was returned for the passed misspelling value.
This commit is contained in:
parent
3ed35574d4
commit
3c5a79710a
@ -1,10 +1,12 @@
|
||||
_ = require 'underscore'
|
||||
|
||||
module.exports =
|
||||
class Point
|
||||
@fromObject: (object) ->
|
||||
if object instanceof Point
|
||||
object
|
||||
else
|
||||
if object instanceof Array
|
||||
if _.isArray(object)
|
||||
[row, column] = object
|
||||
else
|
||||
{ row, column } = object
|
||||
|
@ -31,7 +31,7 @@ class Range
|
||||
new Range(@start.copy(), @end.copy())
|
||||
|
||||
isEqual: (other) ->
|
||||
if other instanceof Array and other.length == 2
|
||||
if _.isArray(other) and other.length == 2
|
||||
other = new Range(other...)
|
||||
|
||||
other.start.isEqual(@start) and other.end.isEqual(@end)
|
||||
|
Loading…
Reference in New Issue
Block a user