Fix Execute Current Statement selection behavior#22095
Open
aasimkhan30 wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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.onRunCurrentStatementto execute selection viarunQuery, otherwise fall back torunCurrentStatement, 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. |
PR Changes
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Description
Fixes #20348.
Updates
mssql.runCurrentStatementso it executes selected SQL when text is selected, and otherwise continues to execute the statement under the cursor. Also updates the command label toExecute Selection or Current Statement (MSSQL)so the Command Palette text matches the behavior.Code Changes Checklist
npm run test)Reviewers: Please read our reviewer guidelines
Validation:
npm run build:extension:typechecknpx vscode-test --label "Unit Tests" --skip-extension-dependencies --run "out/test/unit/mainController.test.js" --grep "onRunCurrentStatement Tests"