Skip to content

fix: align SQL execute gutter icon to actual statement start line - #123

Merged
Blankll merged 1 commit into
masterfrom
fix/sql-gutter-icon-position
Jul 28, 2026
Merged

fix: align SQL execute gutter icon to actual statement start line#123
Blankll merged 1 commit into
masterfrom
fix/sql-gutter-icon-position

Conversation

@Blankll

@Blankll Blankll commented Jul 28, 2026

Copy link
Copy Markdown
Member

Problem

The SQL execute gutter icon was displayed on the wrong line when statements are separated by blank lines or comment lines. For example:

-- Top-selling products by quantity     ← icon was here (L1, correct by luck)
SELECT
  ...
  total_sold DESC LIMIT 5;
                                        ← icon was HERE (L12, blank after ;)
-- Low stock inventory alerts
SELECT                                ← should be HERE (L15)
  ...

The scanner's bufStart sits right after the previous ;, so startLineNumber reflected the position of that blank/comment line instead of the first actual SQL content.

Fix

Added skipLeadingComments() function that scans leading lines and skips:

  • Whitespace-only (blank) lines
  • -- line comments
  • /* */ block comments

The first line with actual SQL content determines the gutter icon position.

Before vs After

Statement Before After Aligns with
1 L1 (comment header) L2 SELECT
2 L12 (blank after ;) L15 SELECT
3 L23 (blank after ;) L25 SELECT
4 L37 (blank after ;) L39 SELECT

Verification

  • 446 existing tests pass (no regressions)
  • 3 new test cases covering blank-line-separated, comment-separated, and adjacent statements
  • Lint clean

The scanner's bufStart sits right after the previous `;`, so when statements are separated by blank lines or comment lines, the gutter icon was displayed on the wrong line (the blank after `;` or the comment line) instead of the first non-whitespace, non-comment line (the actual SQL keyword).

Added skipLeadingComments() to count leading whitespace, `--` line comments, and `/* */` block comments, shifting the icon to the first line with actual SQL content. Includes tests for blank-line-separated and comment-separated statements.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@Blankll
Blankll merged commit b35b9e8 into master Jul 28, 2026
3 checks passed
@Blankll
Blankll deleted the fix/sql-gutter-icon-position branch July 28, 2026 10:16
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.

1 participant