fix watch reordering, to be more flexible to how entities are arranged w.r.t. rows (add-new-rows at top)

This commit is contained in:
Ryan Fleury
2024-10-07 11:52:53 -07:00
parent 232f955786
commit 9ed5134843
2 changed files with 3 additions and 16 deletions
+1 -1
View File
@@ -8315,7 +8315,7 @@ rd_ev_view_rule_expr_num_from_id__meta_entities(U64 id, void *user_data, RD_Enti
U64 entities_base_idx = (U64)!!add_new_at_top;
if(id == max_U64)
{
num = add_new_at_top ? 1 : entities_base_idx + accel->entities.count + 1;
num = add_new_at_top ? 1 : (entities_base_idx + accel->entities.count + 1);
}
else for(U64 idx = 0; idx < accel->entities.count; idx += 1)
{
+2 -15
View File
@@ -1992,13 +1992,6 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
}
}
// rjf: map selection keys to child numbers
U64 selection_numbers[2] =
{
selection_block->expand_view_rule_info->expr_expand_num_from_id(selection_keys_in_block[0].child_id, selection_block->expand_view_rule_info_user_data),
selection_block->expand_view_rule_info->expr_expand_num_from_id(selection_keys_in_block[1].child_id, selection_block->expand_view_rule_info_user_data),
};
// rjf: determine collection info for the block
RD_EntityKind collection_entity_kind = RD_EntityKind_Nil;
E_IRTreeAndType irtree = e_irtree_and_type_from_expr(scratch.arena, selection_block->expr);
@@ -2017,14 +2010,8 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
RD_Entity *last_entity = &d_nil_entity;
if(collection_entity_kind != RD_EntityKind_Nil)
{
RD_EntityList entities_list = rd_query_cached_entity_list_with_kind(collection_entity_kind);
RD_EntityArray entities = rd_entity_array_from_list(scratch.arena, &entities_list);
if(0 < selection_numbers[0] && selection_numbers[0] <= entities.count &&
0 < selection_numbers[1] && selection_numbers[1] <= entities.count)
{
first_entity = entities.v[Min(selection_numbers[0], selection_numbers[1]) - 1];
last_entity = entities.v[Max(selection_numbers[0], selection_numbers[1]) - 1];
}
first_entity = rd_entity_from_id(selection_keys_in_block[0].child_id);
last_entity = rd_entity_from_id(selection_keys_in_block[1].child_id);
}
// rjf: reorder