fix(editor): Format errors show in the results panel + caret jumps to them#36
Merged
Conversation
… to them A formatQuery() syntax error was shown in a brief, easily-missed toast. Now it renders persistently in the results panel (summarized — dropping the "Code: N. DB::Exception:" preamble and the huge "Expected one of: …" tail) and the editor caret jumps to, and scrolls to, the offending position. ClickHouse reports a 1-based offset into the query (newlines counted), so the raw (untrimmed) SQL is sent and the caret lands at N-1. A later successful format clears that error; real run results are never cleared on success (a `formatError` flag distinguishes them). Adds pure parseErrorPos/summarizeError (core/stream.js) and app.dom.editorRevealCaret (editor.js). 753 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QGBS74oUsXarGkCRQKEFLu
Drop summarizeError — the format-error path now puts the original exception text (Code/DB prefix + "Expected one of: …" tail) into the results panel verbatim. Caret-to-position and clear-on-success unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QGBS74oUsXarGkCRQKEFLu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A Format ({} / ⌘⇧↵) syntax error now shows persistently in the results panel and the editor caret jumps to the offending token — instead of a brief toast that vanished before you could read it.
Behavior
Syntax error: failed at position 18 (BEWEEN): BEWEEN 2 AND 3— Code/DB preamble and the long "Expected one of: …" tail trimmed) and stays; the caret moves to (and scrolls to) the position; the editor text is untouched.formatErrorflag tells them apart).How
core/stream.js(pure, tested):parseErrorPos(msg)→ 0-based caret offset from CH's "position N" (1-based, relative to the query, newlines counted → caretN-1; the raw untrimmed SQL is sent so it maps 1:1);summarizeError(msg)→ condensed message.ui/editor.js:app.dom.editorRevealCaret(pos)— focus, set caret, scroll the line into view.ui/app.jsformatQuery(): error → settab.result.error(+formatErrorflag) + reveal caret; success → clear a prior format error.Tests
753 unit tests pass;
stream.js100%,editor.js/app.jswithin the gate. CI also runs the Playwright e2e (Chromium + Firefox).🤖 Generated with Claude Code