Consider a file diff where the cache key is a hash of compared file contents, unambiguous and deterministic. In edit mode, the file diff object is modified and the new contents end up in the cache under the same key (currently the expected behaviour). If a diff is computed from the same contents later and gets the same content-based cacheKey, it will render as the cached edited content.
Making a structural clone of file diff with a different cache key before edit seems to be too late, and the original object is still modified. Ideally entering edit mode would copy the file diff and cached state as needed, then use a random/hash cache key, while making the edits.
Also, the cacheKey docs say this:
Please note that if you modify the contents of the diff in any way, you will need to update the cacheKey.
During edits, it's the library that changes the contents, so arguably the cacheKey should not stay the same to match the above invariant.
On the other hand, with persistState enabled, the cache key is used as the editing session identity, which is contradicting. Perhaps it should be a separate key provided for the edit mode?
Consider a file diff where the cache key is a hash of compared file contents, unambiguous and deterministic. In edit mode, the file diff object is modified and the new contents end up in the cache under the same key (currently the expected behaviour). If a diff is computed from the same contents later and gets the same content-based cacheKey, it will render as the cached edited content.
Making a structural clone of file diff with a different cache key before edit seems to be too late, and the original object is still modified. Ideally entering edit mode would copy the file diff and cached state as needed, then use a random/hash cache key, while making the edits.
Also, the
cacheKeydocs say this:During edits, it's the library that changes the contents, so arguably the
cacheKeyshould not stay the same to match the above invariant.On the other hand, with
persistStateenabled, the cache key is used as the editing session identity, which is contradicting. Perhaps it should be a separate key provided for the edit mode?