mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-30 13:27:51 +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.
|
||||
fn upsert(self: *Self, base: anytype, value: T, new_id: Id, ctx: Context) Id {
|
||||
// If the item already exists, return it.
|
||||
// TODO: we should probably call deleted here on value since
|
||||
// we're using the value already in the map
|
||||
if (self.lookup(base, value, ctx)) |id| return id;
|
||||
if (self.lookup(base, value, ctx)) |id| {
|
||||
// Notify the context that the value is "deleted" because
|
||||
// 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 items = self.items.ptr(base);
|
||||
|
Reference in New Issue
Block a user