Skip to content

fix(mq-lang): unify TextEdit to character offsets, update incremental parser and tests#1405

Merged
harehare merged 2 commits intomainfrom
fix/incremental-parser-textedit
Mar 7, 2026
Merged

fix(mq-lang): unify TextEdit to character offsets, update incremental parser and tests#1405
harehare merged 2 commits intomainfrom
fix/incremental-parser-textedit

Conversation

@harehare
Copy link
Copy Markdown
Owner

@harehare harehare commented Mar 7, 2026

No description provided.

… parser and tests

- TextEdit now uses character offsets (not bytes)
- CharTextEdit reintroduced for explicit character edits
- IncrementalParser updated for Ropey, multi-byte safety, and full-parse fallback
- All affected tests updated for new API

Closes #123 (if relevant)
Copilot AI review requested due to automatic review settings March 7, 2026 14:01
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 7, 2026

Merging this PR will not alter performance

✅ 29 untouched benchmarks


Comparing fix/incremental-parser-textedit (04a8687) with main (b6e3a52)

Open in CodSpeed

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates mq-lang’s CST incremental parsing utilities to treat TextEdit offsets as Unicode character (Rust char) offsets, improving multi-byte text correctness by storing source text as a ropey::Rope.

Changes:

  • Switch IncrementalParser source storage from String to Rope and add byte/char offset conversion helpers.
  • Change TextEdit semantics to character offsets and update apply_edit + tests accordingly, including multi-byte coverage.
  • Add a full-parse fallback when a large fraction of top-level nodes are affected, and add the ropey dependency.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 7 comments.

File Description
crates/mq-lang/src/cst/incremental.rs Implements Rope-backed source storage, character-offset edits, conversion helpers, full-parse fallback, and updates tests/docs.
crates/mq-lang/Cargo.toml Adds ropey dependency to mq-lang.
Cargo.toml Adds ropey to workspace dependencies.
Cargo.lock Locks ropey (and transitive deps) into the workspace lockfile.

@harehare harehare merged commit 1bef26d into main Mar 7, 2026
8 checks passed
@harehare harehare deleted the fix/incremental-parser-textedit branch March 7, 2026 14:44
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