Repository navigation
Conversation
A picture's size in terminal cells was fixed the first time it was shown. LaTeX, TikZ, typst and mermaid pictures kept the size their background render finished at, and a vault image was only re-sent when the pane got narrower, never wider. So a note first previewed in a narrow pane (a split, a window still opening) kept small pictures after the pane grew: a long formula sized for 60 columns stayed a faint dotted line at 152, which is what the 0.12.0 announcement screenshot showed. The image store now keeps each picture's PNG and fits it to the width it is asked for, both ways, every time the preview redraws. A size already sent is reused, so moving between two widths sends nothing new, and at most three sizes of one picture stay in the terminal: the oldest is freed with a delete command. The kept PNGs are capped at 64 MiB; past that the least recently shown picture's bytes go, and it keeps the size it has (a vault image reloads from disk instead). It does not follow a change of the terminal's font size: the cell size is still read once, at the first picture.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Preview pictures now re-fit when the preview pane's width changes.
In 0.12.0 a picture's size in terminal cells was fixed the first time it was shown. LaTeX, TikZ, typst and mermaid pictures kept the size of the moment their render finished, and a vault image only re-sized when the pane got narrower. A note first previewed in a narrow pane (a split, a window still opening) kept small pictures after the pane grew: a long formula sized for 60 columns stayed a faint dotted line at 152, as in the 0.12.0 announcement screenshot.
The image store now keeps each picture's PNG and fits it to the current width both ways. A size already sent is reused, at most three sizes per picture stay in the terminal (the oldest is freed), and the kept PNGs are capped at 64 MiB.
Verified:
go vet ./...,go test ./..., cross-builds for darwin, linux and windows. Five new tests; the two behaviour tests fail on main (the picture stays 30 cells wide after the preview grows to 122) and pass here. In real Ghostty, zn in a pane widened from 60 to 152 columns: on 0.12.0 the long formula stays tiny, with the fix it re-fits.