fix(editor): run-status checkmarks land on the right block, accumulate, and follow edits#225
fix(editor): run-status checkmarks land on the right block, accumulate, and follow edits#225NicolaasGrobler wants to merge 1 commit into
Conversation
…e, and follow edits The per-statement gutter glyphs (green check / red cross) were placed from line numbers frozen at run time and rebuilt on every change. That broke three ways: - A multi-statement *selection* was re-split and its statements numbered relative to the selection (1, 2, 3…) instead of the document, so glyphs landed on the wrong block. - statementResults was reset to [] every run, so running one block wiped the others — never one mark per block. - Glyphs were re-pinned to the frozen line on every rebuild, fighting Monaco's sticky tracking, so they didn't follow edits and didn't clear on cut. Fix: - New pure helpers mapSelectionStatementsToDocumentLines + mergeGlyphResults (src/utils/statementGlyphs.ts, unit-tested). - MainContent: selection statements map back to document-absolute lines; glyphs accumulate (merge + dedup by line) instead of being wiped each run. - QueryEditor: glyphs are id-keyed sticky Monaco decorations — reconcileGlyphs only creates new / removes gone glyphs (survivors keep their live positions), and a throttled pruneGlyphs on content change drops glyphs whose anchor line was edited/cut and keeps survivors' line numbers fresh in tab state. Verified with tsc --noEmit (clean) and npm test (181 passed, incl. 7 new). Fixes #223 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 44 minutes and 47 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #223.
Problem
The per-statement run-status glyphs in the editor gutter (green ✓ / red ✗ next to each SQL block that was run) were stored as line numbers frozen at run time and rebuilt from those numbers on every change. That broke three ways:
statementResultswas reset to[]at the start of each run, so running block 2 erased block 1's checkmark. Never one mark per block.Fix
Agreed target behavior: one checkmark per block that was run, on the correct line, that follows in-place edits and clears when its block is destroyed.
src/utils/statementGlyphs.ts(new, unit-tested):mapSelectionStatementsToDocumentLinesmaps a selection's statements back to document-absolute lines;mergeGlyphResultsaccumulates glyphs (one per block; re-running a block replaces its mark).MainContent.tsx: selection statements now map to document-absolute lines; glyphs accumulate viaappendGlyphResults(merge + dedup by line) instead of being wiped each run; the editor's position writeback goes throughsetGlyphResults.QueryEditor.tsx: gutter glyphs are now id-keyed sticky Monaco decorations.reconcileGlyphsonly creates new / removes gone glyphs (survivors keep their live, Monaco-tracked positions — they ride along as text shifts), and a throttledpruneGlyphson content change drops glyphs whose anchor line was edited/cut and keeps survivors' line numbers fresh in tab state (so they survive a tab switch / remount).Testing
npx tsc --noEmit— clean.npm test— 181 passed, including 7 new tests instatementGlyphs.test.ts(one explicitly pins the relative-vs-absolute line regression; others cover accumulate/dedup).🤖 Generated with Claude Code