Skip to content

Make Explain use the statement at the cursor, like Ctrl+Enter #846

Closed

Description

@EVWorth

Severity: P2.

What happens

On http://localhost:1420/?mock=connected:

  1. Enter SELECT * FROM products; and SELECT * FROM orders; on two lines and put the cursor on line 1.
  2. Ctrl+Enter runs only line 1, as expected.
  3. Click Explain, or press Ctrl+Shift+E. The pane shows "Query Error — Error: Query error: EXPLAIN supports a single statement — 2 were given. Select one statement and re-run."
  4. Click the toolbar Run button. Both statements run ("Result 1 / Result 2" tabs appear), although the hint beside the button reads "Ctrl+Enter / F9", and Ctrl+Enter runs only the current statement.

Cause

  • src/components/editor/SQLEditor.tsx:212-233 (Explain) and :236-257 (Explain Analyze) use model.getValue() when there is no selection.
  • src/components/editor/QueryToolbar.tsx:85-96 (getCurrentSql, used by Run, Explain and Explain Analyze) also returns the whole model.
  • Only the Ctrl+Enter action (SQLEditor.tsx:153-172) uses getStatementAtCursor.

Fix

Use getStatementAtCursor in all of these paths. Alternatively, if the toolbar Run button should run everything, label it "Run all (Ctrl+Shift+Enter)".

Part of #783.

Activity

  1. added
    bug
    on Oct 21, 2026
  2. added 2 commits that reference this issue on Oct 23, 2026
    74a20d5
    3e56feb
  3. added a commit that references this issue on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions