Use _.deepContains

This commit is contained in:
Ben Ogle
2014-06-20 10:50:12 -07:00
parent 72b1821828
commit 593b5b4e36
3 changed files with 5 additions and 19 deletions

View File

@@ -58,7 +58,7 @@
"temp": "0.7.0",
"text-buffer": "^2.4.2",
"theorist": "^1",
"underscore-plus": "^1.4.1",
"underscore-plus": "^1.5.0",
"vm-compatibility-layer": "0.1.0"
},
"packageDependencies": {

View File

@@ -174,11 +174,11 @@ GutterComponent = React.createClass
if previousDecorations?
for decoration in previousDecorations
node.classList.remove(decoration.class) if editor.decorationMatchesType(decoration, 'gutter') and not contains(decorations, decoration)
node.classList.remove(decoration.class) if editor.decorationMatchesType(decoration, 'gutter') and not _.deepContains(decorations, decoration)
if decorations?
for decoration in decorations
if editor.decorationMatchesType(decoration, 'gutter') and not contains(previousDecorations, decoration)
if editor.decorationMatchesType(decoration, 'gutter') and not _.deepContains(previousDecorations, decoration)
node.classList.add(decoration.class)
unless @screenRowsByLineNumberId[lineNumberId] is screenRow
@@ -211,10 +211,3 @@ GutterComponent = React.createClass
unless width is @measuredWidth
@measuredWidth = width
@props.onWidthChanged?(width)
# Created because underscore uses === not _.isEqual, which we need
contains = (array, target) ->
return false unless array?
for object in array
return true if _.isEqual(object, target)
false

View File

@@ -215,11 +215,11 @@ LinesComponent = React.createClass
if previousDecorations = @renderedDecorationsByLineId[line.id]
for decoration in previousDecorations
lineNode.classList.remove(decoration.class) if editor.decorationMatchesType(decoration, 'line') and not contains(decorations, decoration)
lineNode.classList.remove(decoration.class) if editor.decorationMatchesType(decoration, 'line') and not _.deepContains(decorations, decoration)
if decorations = lineDecorations[screenRow]
for decoration in decorations
if editor.decorationMatchesType(decoration, 'line') and not contains(previousDecorations, decoration)
if editor.decorationMatchesType(decoration, 'line') and not _.deepContains(previousDecorations, decoration)
lineNode.classList.add(decoration.class)
return
@@ -292,10 +292,3 @@ LinesComponent = React.createClass
clearScopedCharWidths: ->
@measuredLines.clear()
@props.editor.clearScopedCharWidths()
# Created because underscore uses === not _.isEqual, which we need
contains = (array, target) ->
return false unless array?
for object in array
return true if _.isEqual(object, target)
false