Skip to content

Document linemaps in the grimoire#809

Draft
jackfirth wants to merge 10 commits into
masterfrom
grimoire-linemap
Draft

Document linemaps in the grimoire#809
jackfirth wants to merge 10 commits into
masterfrom
grimoire-linemap

Conversation

@jackfirth

@jackfirth jackfirth commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Adds linemaps to the grimoire.

jackfirth and others added 3 commits July 11, 2026 00:08
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The linemap-lines contract has always promised immutable strings, but the
implementation built lines with substring, which returns mutable ones. Any
use of linemap-lines through the contract boundary raised a broke-its-own-
contract error. It has no callers outside the module, so nothing noticed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview: https://resyntax.notjack.space/preview/809/

@github-actions github-actions 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.

Resyntax analyzed 4 files in this pull request and found no issues.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@github-actions github-actions 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.

Resyntax analyzed 4 files in this pull request and found no issues.

@coveralls

coveralls commented Jul 11, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 95.362% (+0.04%) from 95.319% — grimoire-linemap into master

jackfirth and others added 2 commits July 11, 2026 00:35
Linemaps are built from strings, and Racket string APIs (and Resyntax's
string replacements) index characters from zero. One-indexed positions are
a file port and IDE convention that doesn't belong here. Line numbers stay
one-indexed, since they're primarily useful in UI contexts. Every caller
was converting with add1/sub1 at the boundary; those shims are now gone,
and syntax-line-range converts from one-indexed syntax positions itself.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The fix for #272 (Windows \r\n newlines breaking analysis, PR #274) lives
in with-input-from-source, which reencodes every source port with newline
conversion. That behavior and the invariant it protects were undocumented.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@github-actions github-actions 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.

Resyntax analyzed 4 files in this pull request and has added suggestions.

Comment thread private/syntax-replacement.rkt

@github-actions github-actions 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.

Resyntax analyzed 4 files in this pull request and has added suggestions.

Comment thread private/syntax-replacement.rkt
jackfirth and others added 2 commits July 11, 2026 00:56
Previously only the port-reading path normalized newlines, so two string
sources could be non-equal? yet denote the same text via source->string.
Normalizing eagerly in the struct guards removes that corner case as early
in the data flow as possible. The guard conversion matches the full set of
sequences that reencode-input-port converts, verified empirically: \r\n,
\r NEL, \r, NEL, and LS all become \n.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Rather than a regexp that reproduces the port's conversion behavior, round-
trip the string through an actual newline-converting reencoded port. Slightly
more copying, but it can never fall out of sync with what reading a source
does.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@github-actions github-actions 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.

Resyntax analyzed 5 files in this pull request and has added suggestions.

Comment thread private/syntax-replacement.rkt

@github-actions github-actions 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.

Resyntax analyzed 5 files in this pull request and has added suggestions.

Comment thread private/syntax-replacement.rkt
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@github-actions github-actions 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.

Resyntax analyzed 5 files in this pull request and has added suggestions.

Comment thread private/syntax-replacement.rkt
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@github-actions github-actions 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.

Resyntax analyzed 5 files in this pull request and has added suggestions.

Comment thread private/syntax-replacement.rkt
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.

2 participants