Repository navigation
feat(par): make first-line-indent foldable - #7123
Closed
JuanHPassos wants to merge 8 commits into
Closed
JuanHPassos wants to merge 8 commits into
JuanHPassos wants to merge 8 commits into
Conversation
Contributor
Author
|
Hi @MDLC01 , I think I’m done! Could you review my PR? |
Collaborator
|
The team is busy right now with the release of Typst 0.14.0, but they will likely review your PR after the new version is released. |
Member
|
Given that
I'll close this. |
YDX-2147483647
pushed a commit
to YDX-2147483647/typst
that referenced
this pull request
Jan 23, 2026
feat(par): make first-line-indent foldable style: apply rustfmt
YDX-2147483647
pushed a commit
to YDX-2147483647/typst
that referenced
this pull request
Jan 27, 2026
feat(par): make first-line-indent foldable style: apply rustfmt
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.
Closes #7052
Summary
This PR makes the
par.first-line-indentproperty foldable, allowing for partial updates.Currently,
first-line-indentis treated as a single unit. If a template or asetrule defines a full value like(amount: 2em, all: false), a user cannot update just one key without overriding the entire struct. For example, applyingset par(first-line-indent: (all: true))would reset theamountto its default value, which is an undesirable side effect.With this change, partial dictionaries are merged with the existing style. The same
setrule will now correctly preserve theamount, resulting in(amount: 2em, all: true). This makes style composition more intuitive and powerful, consistent with other foldable properties in Typst.Implementation
The folding behavior was implemented idiomatically using the framework's built-in mechanisms:
first_line_indentfield inParElemis now marked with the#[fold]attribute.FirstLineIndentstruct implements thestyles::Foldtrait to define how new values are merged with existing ones.cast!macro forFirstLineIndentwas adjusted to correctly handle partial dictionaries by supplying default values for missing keys, which is necessary for thefoldlogic to work.Testing
The changes were verified with a test
.typfile that covers the following scenarios:all: truecorrectly preserves a previously setamount.amountcorrectly preserves a previously setall: true.amountandallat the same time correctly overrides the previous style.lengthshorthand (e.g.,10pt) continues to work as expected.All tests passed, and the visual output in the generated PDF matches the expected behavior.
Checklist