Skip to content

fix: keep formatting out of unselected lines - #1412

Open
MrPunyapal wants to merge 2 commits into
dev-null-sh:productionfrom
MrPunyapal:fix/markdown-selection-trailing-newline
Open

MrPunyapal wants to merge 2 commits into
dev-null-sh:productionfrom
MrPunyapal:fix/markdown-selection-trailing-newline

Conversation

@MrPunyapal

@MrPunyapal MrPunyapal commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Applying inline formatting at a collapsed selection near a trailing newline can include text outside the selected line.

Change

Keeps formatting within the selected range and preserves the caret behavior for collapsed and expanded selections.

Tests

The full JavaScript unit suite passed (224 tests). Type checks and lint passed.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed line-prefix formatting so a selection ending immediately after a newline no longer includes the following line.
    • Improved formatting of selections that begin with a newline, ensuring the selected content is formatted correctly.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

formatMarkdown now adjusts the line-range endpoint when a nonempty selection ends immediately after a newline. Tests cover bulleted and numbered formatting at this boundary and bulleted formatting with a leading newline.

Changes: Markdown formatting

Layer / File(s) Summary
Selection boundary handling and regression tests
resources/js/lib/markdown-format.ts, tests/Unit/MarkdownFormat.test.ts
When a nonempty selection ends immediately after a newline, formatMarkdown excludes the following line. Tests cover bulleted and numbered selections at this boundary and a selection containing a leading newline.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: nunomaduro

Merge Risk: Minimal · up to a9da0

The selection boundary fix is supported by the implementation and regression coverage, with no actionable merge-blocking risk identified.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preventing Markdown formatting from affecting unselected lines.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6470720f-add8-4cfb-bb9e-d3f469e26ef0
Commits

Reviewing files that changed from the base of the PR and between 0a1c95a and a9da0a2.

Files selected for processing: 2
  • resources/js/lib/markdown-format.ts
  • tests/Unit/MarkdownFormat.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@MrPunyapal
MrPunyapal force-pushed the fix/markdown-selection-trailing-newline branch from f952c83 to 0a1c95a Compare November 3, 2026 05:56
@MrPunyapal
MrPunyapal marked this pull request as ready for review November 3, 2026 06:01

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread resources/js/lib/markdown-format.ts Resolved
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.

1 participant