Change image storage to use new ExtendedAttrs payload field#5879
Change image storage to use new ExtendedAttrs payload field#5879PerBothner wants to merge 6 commits into
Conversation
|
An optional optimization is to replace A further possibility would be to remove the |
| continue; | ||
| } | ||
| e = maybeImg; | ||
| line.loadCell(col, workCell); |
There was a problem hiding this comment.
It's a bit of a code smell that we touch private API here at all. If the image addon only needs to attach extended data, could we make a real API to allow attaching data using an arbitrary key?
interface IBufferCell {
setCustomData(key: string, value: object);
getCustomData(key: string): object | undefined
}Even adding this public API to xterm.d.ts and keeping the internals access as-is would be preferable to bringing in loadCell/CellData imo.
@jerch does this look like the shape you would expect?
There was a problem hiding this comment.
The setCustomData/getCustomData functionality is certainly nice and general - but it could be expensive. Conceptually we're adding a separate Map for each cell - or at least one for every cell with HAS_EXTENDED. Presumably we'd want keep ExtendedAttrs (or its replacement) immutable.
We can replace the loadCell with the public getCell method - but ImageStore._writeToCell need the ability to modify a cell, currently done with setCell. What is the public API equivalent? From what I understand, getCell returns a copy of the state of a cell. Calling setCustomData presumably only updates the copy - we need to write back to the BufferLine.
There was a problem hiding this comment.
This comment below for a (slightly) more detailed suggestion. I've focused on the internal API; we can discuss the public API once the concepts are clear.
Co-authored-by: Daniel Imms <2193314+Tyriar@users.noreply.github.com>
|
On further thought, I think it might be worthwhile to consider merging the I believe the changes to Marker in PR #5853 provide a good foundation for this model. That change attaches the Markers directly to a With this change, I think we can gradually get rid of However, I do think it makes sense to merge in PR #5853 (which includes the changes in this PR) before going further with the "custom data" route. |
|
I merged from upstream and all tests pass. Can we merge this? It is blocking BufferLine/LogicalLine changes. @Tyriar requested one small change (which I believe I've made), and potentially a more general API (which is a bigger project that should be considered in conjunction with other Marker/Decorator changes). |
Adds a general-purpose
payloadhook toExtendedAttrs. This allows us to get rid of theExtendedAttrsImagelogic, which can easily conflict with other extensions.The PR avoids looking into
BufferLineinternals by instead usingloadCellandsetCell. The calls toloadCellmay add slightly more overhead; if that is measurable, we can look into reducing the number ofloadCellcalls.This is an implementation of this suggestion.
It might make sense for a future update to remove the
urlIdfield fromExtendedAttrsand instead use the generalpayloadhook.