Skip to content

Reorder FigureCaption fields for nicer PlainText representation#6447

Closed
cAttte wants to merge 1 commit intotypst:mainfrom
cAttte:figcap
Closed

Reorder FigureCaption fields for nicer PlainText representation#6447
cAttte wants to merge 1 commit intotypst:mainfrom
cAttte:figcap

Conversation

@cAttte
Copy link
Contributor

@cAttte cAttte commented Jun 14, 2025

hi, i noticed that the plaintext representation of figure captions was off, for example in tooltips:
image

i fixed this by just reordering the fields of FigureCaption (moving supplement before body). code looks a bit weird with the #[synthesized]s out of order buuut anyway here's how it looks now, for example in a completion:

Completion {
    kind: Label,
    label: "yea",
    apply: None,
    detail: Some(
        "Figure: hi",
    ),
}

hmm i should probably add a test for this right? where exactly should it go?

@laurmaedje
Copy link
Member

The intent was that the tooltip just says "hi" and this used to work. I think this regressed at some point. The code that creates this string is here:

for elem in document.introspector.all() {
let Some(label) = elem.label() else { continue };
let details = elem
.get_by_name("caption")
.or_else(|_| elem.get_by_name("body"))
.ok()
.and_then(|field| match field {
Value::Content(content) => Some(content),
_ => None,
})
.as_ref()
.unwrap_or(elem)
.plain_text();
output.push((label, Some(details)));
}

Maybe it's falling back to the unwrap_or(elem) branch for some reason even though it shouldn't?

@laurmaedje laurmaedje added the waiting-on-author Pull request waits on author label Jun 30, 2025
@laurmaedje
Copy link
Member

Superseded by #6580.

Thanks still for bringing my attention to this! I had seen the bug before, but had completely forgotten about it.

@laurmaedje laurmaedje closed this Jul 9, 2025
@laurmaedje laurmaedje removed the waiting-on-author Pull request waits on author label Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants