trice icon indicating copy to clipboard operation
trice copied to clipboard

Re-use IDs inside til.json == Remove shared IDs option and extend trice u to consider location information for duplicate trice strings

Open rokath opened this issue 1 year ago β€’ 1 comments

After trice z . all IDs are removed from target source code, but remain in til.json. When then doing trice u ., all IDs are generated newly and added to til.json. This needs change. When update finds a TRICE( Id(0), ... it should lookup til.json first for an already assigned ID to this trice. ThatΒ΄s easy if all trices differ, but an identical trice could occur 100 times in the project, each with an other ID but different location information, and we want to restore the same ID for each of it. Thats where li.json comes in. So, if we have 5 times the same trice in 5 consecuitive lines and before some code was added, lets say a single line, then the first and the last trice do not match but the 3 between them. Go starts several threads of course, but they all work on different files parallel, is my assumption. So the algorithm should be:

  • If the trice exists only once, its trivial, otherwise:
  • If a (not single) trice was moved to a different file, it gets a new ID. So only in-same-file trices are considered.
  • Iterate over til.json the identical trices and
  • 2 Options:
    1. Take first matching or otherwise closest location: That can fail if code was inserted.
    2. Take the first location: That can fail if an identical trice was inserted before the others or moved there from the end.
  • In fact both options seam to be good enough. Opton 2 seems to be easier to implement.

rokath avatar Aug 28 '22 14:08 rokath

It is not that important not to switch the ID of identical **trices ** inside of one file, but would be nice. When an ID was inserted, it should be marked somehow to not use it a 2nd time.

rokath avatar Sep 14 '22 20:09 rokath

Done in v0.61.0 with trice insert

rokath avatar Jul 24 '23 11:07 rokath