Skip to content

Fix Execute Current Statement selection behavior#22095

Open
aasimkhan30 wants to merge 3 commits into
mainfrom
aasim/fix/20348
Open

Fix Execute Current Statement selection behavior#22095
aasimkhan30 wants to merge 3 commits into
mainfrom
aasim/fix/20348

Conversation

@aasimkhan30
Copy link
Copy Markdown
Contributor

Description

Fixes #20348.

Updates mssql.runCurrentStatement so it executes selected SQL when text is selected, and otherwise continues to execute the statement under the cursor. Also updates the command label to Execute Selection or Current Statement (MSSQL) so the Command Palette text matches the behavior.

Code Changes Checklist

  • New or updated unit tests added
  • All existing tests pass (npm run test)
  • Code follows contributing guidelines
  • Telemetry/logging updated if relevant
  • No regressions or UX breakage

Reviewers: Please read our reviewer guidelines

Validation:

  • npm run build:extension:typecheck
  • npx vscode-test --label "Unit Tests" --skip-extension-dependencies --run "out/test/unit/mainController.test.js" --grep "onRunCurrentStatement Tests"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses #20348 by aligning mssql.runCurrentStatement behavior and its Command Palette label: it now executes the selected SQL text when a non-empty selection exists, otherwise it executes the statement under the cursor.

Changes:

  • Updated MainController.onRunCurrentStatement to execute selection via runQuery, otherwise fall back to runCurrentStatement, with added guards for empty documents, whitespace-only selections, and multi-selection mode.
  • Added unit tests covering selection vs. current-statement execution and edge cases (empty doc, whitespace selection, multiple selections).
  • Updated the localized command label to “Execute Selection or Current Statement (MSSQL)”.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
localization/xliff/vscode-mssql.xlf Updates the localized command title string for mssql.runCurrentStatement.
extensions/mssql/test/unit/mainController.test.ts Adds unit tests for updated onRunCurrentStatement selection behavior and edge cases.
extensions/mssql/src/controllers/mainController.ts Implements “selection or current statement” execution logic and multi-selection guard.
extensions/mssql/package.nls.json Updates the Command Palette label for mssql.runCurrentStatement.

Comment thread extensions/mssql/test/unit/mainController.test.ts
Comment thread extensions/mssql/test/unit/mainController.test.ts
Comment thread extensions/mssql/test/unit/mainController.test.ts
@github-actions
Copy link
Copy Markdown

PR Changes

Category Target Branch PR Branch Difference
vscode-mssql VSIX 78066 KB 78066 KB ⚪ 0 KB ( 0% )
sql-database-projects VSIX 6310 KB 6310 KB ⚪ 0 KB ( 0% )
data-workspace VSIX 535 KB 535 KB ⚪ 0 KB ( 0% )
keymap VSIX 7 KB 7 KB ⚪ 0 KB ( 0% )

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.86%. Comparing base (bd2a245) to head (0dac57f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #22095      +/-   ##
==========================================
+ Coverage   74.83%   74.86%   +0.03%     
==========================================
  Files         394      394              
  Lines      120403   120434      +31     
  Branches     7197     7202       +5     
==========================================
+ Hits        90102    90163      +61     
+ Misses      30301    30271      -30     
Flag Coverage Δ
data-workspace 77.10% <ø> (ø)
mssql 74.55% <100.00%> (+0.03%) ⬆️
sqlproj 77.33% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
extensions/mssql/src/controllers/mainController.ts 37.49% <100.00%> (+1.44%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

[Bug]: Command label “MSSQL: Execute Current Statement” does not reflect actual behavior

3 participants