Skip to content

ArrayHierarchicalCollection.set() doesn't sort if there's a filter. #212

Description

@player-03
final collection:ArrayHierarchicalCollection<Int>
	= new ArrayHierarchicalCollection<Int>([3, 2, 1]);

trace(collection.get([0]) + " == " + 3);
trace(collection.get([1]) + " == " + 2);

collection.sortCompareFunction = Reflect.compare; //Ascending order
trace(collection.get([0]) + " == " + 1);
trace(collection.get([1]) + " == " + 2);

collection.filterFunction = (value:Int) -> value != 2;
trace(collection.get([0]) + " == " + 1);
trace(collection.get([1]) + " == " + 3);

//Replace 1 with 5 so the source array is [3, 2, 5].
//With 2 filtered out, it should show up as [3, 5].
collection.set([0], 5);
trace(collection.get([0]) + " == " + 3); //5 == 3
trace(collection.get([1]) + " == " + 5); //3 == 5

@:privateAccess collection.refreshFilterAndSort();
trace(collection.get([0]) + " == " + 3);
trace(collection.get([1]) + " == " + 5);

There aren't enough branches to handle this case! But really, there are too many branches, that's the only reason this got missed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions