feat(frontend): run statement at cursor on Cmd+Enter#464
Open
maximumbreak wants to merge 2 commits into
Open
Conversation
Cmd+Enter, Ctrl/Cmd+F5, and Explain now run/explain the SQL statement the cursor is inside when nothing is selected, instead of the whole file or a "pick a statement" popup. A subtle highlight shows which statement is armed to run, and disappears once you make a selection. Whole-file execution is still available by selecting all text first.
…h other Running two different statements/tables back to back on the same tab (now easy via cursor-driven Run) exposed two related bugs: an in-flight column-metadata fetch could resolve after a newer run and overwrite it with the wrong table's PK/columns, and every pagination/refresh action (including post-edit-save refresh) re-sent the whole editor buffer instead of the single statement that produced the current result, which Postgres rejects as "multiple commands in a prepared statement" when the buffer has more than one. Both are fixed by tracking the exact last-run statement per tab and a generation counter that lets stale async responses detect and drop themselves.
maximumbreak
force-pushed
the
feature/run-statement-at-cursor
branch
from
July 12, 2026 07:02
4ca7ab7 to
d9d3d65
Compare
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.
Demo :
demo.mov
Summary
Details
findStatementAtOffsettosqlSplitter, resolving which statement a cursor offset falls inside using the splitter's existing (previously unused) per-statementrangedata. A cursor in the gap between two statements resolves to the preceding one; a cursor before the first statement does nothing.handleRunButton/handleExplainButtoninEditor.tsxnow resolve the statement at the cursor via a shared helper instead of falling back to the whole file.SqlEditorWrappergained an opt-indialectprop that drives the cursor-statement highlight decoration; other consumers of the component are unaffected since they don't pass it.runQuerynow tracks the exact statement it last ran per tab and a per-tab generation counter, so async responses (PK/column metadata fetch, the main query result) from a superseded run are dropped instead of clobbering a newer run's state, and pagination/refresh call sites now re-run "whatever's currently shown" instead of the raw multi-statement editor buffer.QuerySelectionModalis left in the codebase but no longer reachable from the Run/Explain paths.Test plan
pnpm test— 2797 tests pass, including new coverage forfindStatementAtOffset(statement boundaries, gaps between statements, before/after the statement list, single-statement files)pnpm typecheck/eslintcleanLet me know if you'd like it trimmed down or adjusted before you post it.