Skip to content

fix: cap text right indentation to prevent overflow from the editor#3177

Closed
tiagocmendes wants to merge 1 commit intosuperdoc-dev:mainfrom
tiagocmendes:fix/max-text-indent
Closed

fix: cap text right indentation to prevent overflow from the editor#3177
tiagocmendes wants to merge 1 commit intosuperdoc-dev:mainfrom
tiagocmendes:fix/max-text-indent

Conversation

@tiagocmendes
Copy link
Copy Markdown

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

  • Add maxIndentPoints constant (9360 points / 6.5 inches) to define the maximum allowed indentation
  • Add validation in calculateNewIndentation to clamp left indent values at the maximum threshold
  • Add test case to verify increaseTextIndent() properly caps at 9360 points when near the maximum
  • Prevents increaseTextIndent() from creating excessively large indentation values through repeated increments

Technical Details: The fix is applied in the calculateNewIndentation function 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.

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>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +68 to +70
if (left > maxIndentPoints) {
left = maxIndentPoints;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@tiagocmendes tiagocmendes closed this by deleting the head repository May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant