- commit
- cb8e90663c5062d8cbcb6bf68792983c9964f325
- parent
- a7587c6600841df793cc26628514f37be8628fe7
- author
- Dami <dami.etoile@gmail.com>
| M | internal/ | 6 | ++++++ |
| M | internal/ | 9 | ++++++++- |
@@ -217,6 +217,12 @@ func TestChartImages(t *testing.T) {
217217 if len(raw) != 1 {218218 t.Errorf("changed chart not sent")219219 }220+ // The old image and its placement are freed before the new one is221+ // sent, so the terminal sizes it by the new placement, not the first.222+ del, send := strings.Index(raw[0], "a=d,d=I,i=16"), strings.Index(raw[0], "a=T,")223+ if del < 0 || send < del {224+ t.Errorf("resent image doesn't free the old placement first: %q", raw[0][:min(len(raw[0]), 80)])225+ }220226 // Deleting the chart frees its image.221227 raw = nil222228 m.sheet.DeleteChart(0)@@ -163,10 +163,17 @@ func (m *Model) syncImages() tea.Cmd {
163163 w, h := chartInner(c)164164 d := m.sheet.ChartData(c)165165 key := fmt.Sprintf("%v %v %d %d %v %v", c.Type, d, w, h, o, pal)166- if m.term.sent[id] == key {166+ prev, resent := m.term.sent[id]167+ if prev == key {167168 continue168169 }169170 m.term.sent[id] = key171+ if resent {172+ // Free the old image and its placement first: Ghostty keeps173+ // every virtual placement of an id and sizes the image by the174+ // oldest, so a chart that grew would draw at its old size.175+ out.WriteString(chart.Delete(id, m.term.wrap))176+ }170177 span := telemetry.Start("chart.image", slog.String("type", c.Type.String()), slog.Int("w", w), slog.Int("h", h))171178 g := chart.Draw(c.Type, d, w, h, o)172179 img := chart.Image(c.Type, d, w, h, o, pal)