mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-01 22:37:32 +03:00
terminal: RefCountedSet should call deleted on upsert
This commit is contained in:
@ -476,9 +476,13 @@ pub fn RefCountedSet(
|
|||||||
/// is ignored and the existing item's ID is returned.
|
/// is ignored and the existing item's ID is returned.
|
||||||
fn upsert(self: *Self, base: anytype, value: T, new_id: Id, ctx: Context) Id {
|
fn upsert(self: *Self, base: anytype, value: T, new_id: Id, ctx: Context) Id {
|
||||||
// If the item already exists, return it.
|
// If the item already exists, return it.
|
||||||
// TODO: we should probably call deleted here on value since
|
if (self.lookup(base, value, ctx)) |id| {
|
||||||
// we're using the value already in the map
|
// Notify the context that the value is "deleted" because
|
||||||
if (self.lookup(base, value, ctx)) |id| return id;
|
// we're reusing the existing value in the set. This allows
|
||||||
|
// callers to clean up any resources associated with the value.
|
||||||
|
if (comptime @hasDecl(Context, "deleted")) ctx.deleted(value);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
const table = self.table.ptr(base);
|
const table = self.table.ptr(base);
|
||||||
const items = self.items.ptr(base);
|
const items = self.items.ptr(base);
|
||||||
|
Reference in New Issue
Block a user