fix: cap text right indentation to prevent overflow from the editor#3177
fix: cap text right indentation to prevent overflow from the editor#3177tiagocmendes wants to merge 1 commit intosuperdoc-dev:mainfrom
Conversation
Add maxIndentPoints constant and enforce limit in calculateNewIndentation to prevent excessive paragraph indentation values. Add test coverage for maximum indent behavior. Co-authored-by: Copilot <copilot@github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c0a495395c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (left > maxIndentPoints) { | ||
| left = maxIndentPoints; | ||
| } |
There was a problem hiding this comment.
Limit the cap to positive indent changes
When the selected paragraph already has a left indent above 9360 twips (for example from an imported DOCX or API-created document), this clamp also runs during decreaseTextIndent() because calculateNewIndentation is shared for both deltas. A single decrease from 15000 twips becomes 9360 instead of subtracting the normal 720 twips, causing an unexpectedly large formatting change rather than a one-step outdent; only positive/increase changes should be capped here.
Useful? React with 👍 / 👎.
Summary
Adds a maximum limit to paragraph text indentation to prevent values from exceeding 6.5 inches (9360 points). This ensures indentation stays within reasonable bounds and matches common word processor constraints, and not overflows the editor.
Before
indent-before.mov
After
Screen.Recording.2026-05-05.at.23.57.32.mov
Changes
maxIndentPointsconstant (9360 points / 6.5 inches) to define the maximum allowed indentationcalculateNewIndentationto clamp left indent values at the maximum thresholdincreaseTextIndent()properly caps at 9360 points when near the maximumincreaseTextIndent()from creating excessively large indentation values through repeated incrementsTechnical Details: The fix is applied in the
calculateNewIndentationfunction after computing the new indent value but before the zero-check, ensuring the maximum is enforced for both initial indents and incremental changes.Test coverage: New test verifies that when starting from 9000 points (near max), calling
increaseTextIndent()caps the result at exactly 9360 points instead of allowing it to exceed the limit.