4 ms·
crafty, but for your consideration: that places the burden upon every library author to be "accounting accurate" to any edits, and the only way anyone would kno
by mdaniel 3y ago
crafty, but for your consideration: that places the burden upon every library author to be "accounting accurate" to any edits, and the only way anyone would know that it's not correct is to visually inspect the output text
also, as I get older I have a deeper and deeper appreciation that "offset" and "text" are words that are fraught with peril
- j-pb 3y agoFair critique, but shouldn't strings be immutable anyways? Once you bring editing into play, you'll probably either want something like a rope or some CRDT and then you have more effective means of tracking positions, than manual offset computations, as part of the data-structure.
- feoren 3y agoWhat about using inline "floating" checkpoints for the ranges, instead of character indexes? {text: "Lorem ipsum {{1}}dolor sit {{2}}amet{{3}}, consectetur{{4}} adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", annotations: [{tag: "sometag", ranges: [{from: 1, to: 3}]}, {tag: "sometothertag", ranges: [{from: 2, to: 4}]}