Skip to content

[Repo Assist] Make MarkdownRange non-optional in MarkdownSpan and MarkdownParagraph (fixes #742)#1067

Open
github-actions[bot] wants to merge 3 commits intomainfrom
repo-assist/fix-issue-742-non-optional-ranges-05198c9c9736942f
Open

[Repo Assist] Make MarkdownRange non-optional in MarkdownSpan and MarkdownParagraph (fixes #742)#1067
github-actions[bot] wants to merge 3 commits intomainfrom
repo-assist/fix-issue-742-non-optional-ranges-05198c9c9736942f

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 3, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant, in response to a /repo-assist command on issue #742.

Summary

Closes #742

This PR makes the range field non-optional in all MarkdownSpan and MarkdownParagraph discriminated union cases, as requested by @dsyme and originally reported by @artempyanykh.

Previously, every Markdown AST node had range: MarkdownRange option. Now all cases have range: MarkdownRange, with MarkdownRange.zero used as a fallback where no source range is available.

Root Cause

The range field was originally defined as optional throughout the AST. The one place where it became None during parsing was in updateCurrentRange when the line list was empty. This has now been fixed to return MarkdownRange.zero instead.

Changes

  • MarkdownModel.fs – All range: MarkdownRange optionrange: MarkdownRange in MarkdownSpan and MarkdownParagraph DU cases; NoneMarkdownRange.zero in Dsl module
  • MarkdownInlineParser.fsCurrentRange field simplified from option to plain MarkdownRange; all option-matching removed from range computations
  • MarkdownBlockParser.fsupdateCurrentRange returns MarkdownRange directly (with MarkdownRange.zero for empty input)
  • Markdown.fs – Removed Some() wrapper from initial CurrentRange
  • Transformations.fs, ParseScript.fs, Formatting.fs, Literate.fs – All range None args replaced with MarkdownRange.zero
  • tests/ – Updated test expectations: Some({StartLine = ...; ...}){StartLine = ...; ...}
  • RELEASE_NOTES.md – Added changelog entry

Breaking Change

This is a breaking API change for any code that:

  • Pattern-matches on MarkdownSpan or MarkdownParagraph with named range fields
  • Constructs MarkdownSpan or MarkdownParagraph values with explicit range arguments
  • Uses range.Value or matches Some r/None on the range field

Migration: replace range: MarkdownRange optionrange: MarkdownRange, and any None range → MarkdownRange.zero.

Test Status

Build: ✅ Passed
Tests: ✅ All 257 tests passed

Generated by Repo Assist for issue #742

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@da02dddebe71d9a937665abdcd1f5214dab852a7

Replace all `range: MarkdownRange option` fields in the MarkdownSpan
and MarkdownParagraph discriminated unions with `range: MarkdownRange`,
using `MarkdownRange.zero` as the fallback where no range was available.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review March 4, 2026 09:12
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.

Optional range information for Markdown elements

1 participant