Skip to content

Document linemaps in the grimoire#809

Merged
jackfirth merged 17 commits into
masterfrom
grimoire-linemap
Jul 17, 2026
Merged

Document linemaps in the grimoire#809
jackfirth merged 17 commits into
masterfrom
grimoire-linemap

Conversation

@jackfirth

@jackfirth jackfirth commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Adds linemaps to the grimoire.

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

@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: 96.563% (+0.05%) from 96.517% — grimoire-linemap into master

@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 Outdated

@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 Outdated

@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 Outdated

@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 Outdated

@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 Outdated

@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 Outdated

@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 Outdated

@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 Outdated

@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 found no issues.

jackfirth and others added 13 commits July 16, 2026 00:27
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>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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>
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>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Applies Resyntax's own suggestion from the PR analyzer bot, which the
GitHub UI couldn't apply because the suggestion range overlapped deleted
lines.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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 found no issues.

@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 found no issues.

Positions past the end of the string now raise contract errors instead of
silently mapping to the last line, and syntax-line-range checks that the
syntax object's source location fits within the linemap's string. The
position equal to the string's length remains valid: it's the exclusive
end position that callers legitimately pass, and it belongs to the last
line.

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 6 files in this pull request and found no issues.

jackfirth and others added 2 commits July 16, 2026 22:40
@jackfirth
jackfirth marked this pull request as ready for review July 17, 2026 05:44

@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 6 files in this pull request and found no issues.

@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 6 files in this pull request and found no issues.

@jackfirth
jackfirth merged commit 8f76e08 into master Jul 17, 2026
13 checks passed
@jackfirth
jackfirth deleted the grimoire-linemap branch July 17, 2026 05:58
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