config icon indicating copy to clipboard operation
config copied to clipboard

Merging structural changes and unnamed lists

Open jankowtf opened this issue 5 years ago • 3 comments

Hi!

This is my first pull request here, so hope I'm doing everything correctly. Hope the comments are sufficient to explain my thinking, please reach out if something should be unclear.

  • Added functionality to merge structural changes (named to unnamed list) and unnamed lists based on UID convention
  • Added unit tests for new merge functionality (probably will have to add these in a separate PR -> #32)

jankowtf avatar Jan 03 '21 20:01 jankowtf

@andrie Could you review this when you have some time later this week. My biggest concern would be whether this might break any existing configs -- at first glance I don't see any obvious issues but it's worth additional scruitiny.

jjallaire avatar Jan 04 '21 01:01 jjallaire

@andrie @jjallaire: maybe worth mentioning that the else part in

if (!all(is.null(names(merged_list)))) {
  # This implies a structural change from named list to unnamed list and
  # thus the new content should be returned all together
  overlay_list
} else {
  # This is implies no structural break, but an unnamed list needs to be
  # merged with another unnamed list. As this is a non-trivial task with
  # lots of possible solutions, the current merging mechanism is a
  # simple solution that expects the first element of the sublists to
  # act as a unique identifier

  # Merge lists but with 'overlay_list' taking the lead
  merged_list <- append(overlay_list, merged_list)
  # Extract UIDs
  uids <- extract_uids(merged_list)
  # Drop duplicated UIDs and sort based on UIDs
  merged_list[!duplicated(uids)][order(unique(uids))]
}

was only an idea which idepends upon some made-up conventions.

It might make more sense to also go with overlay_list in such cases in order not change too much of the existing behavior. Along the lines of #25

jankowtf avatar Jan 04 '21 13:01 jankowtf

Just wonder if this will be merged, for 2 years has passed.

psychelzh avatar Apr 26 '23 09:04 psychelzh