Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions extensions/mssql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,12 @@
"default": false,
"scope": "resource"
},
"mssql.showBatchMessages": {
"type": "boolean",
"description": "%mssql.showBatchMessages%",
"default": true,
"scope": "resource"
},
"mssql.splitPaneSelection": {
"type": "string",
"description": "%mssql.splitPaneSelection%",
Expand Down
1 change: 1 addition & 0 deletions extensions/mssql/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"mssql.copyIncludeHeaders": "[Optional] Configuration options for copying results from the Results View",
"mssql.copyRemoveNewLine": "[Optional] Configuration options for copying multi-line results from the Results View",
"mssql.showBatchTime": "[Optional] Should execution time be shown for individual batches",
"mssql.showBatchMessages": "[Optional] Show batch start and completion messages including 'Started executing query at...' and 'Commands completed successfully' messages.",
"mssql.splitPaneSelection": "[Optional] Configuration options for which column new result panes should open in",
"mssql.preventAutoExecuteScript": "Prevent automatic execution of scripts (e.g., 'Select Top 1000'). When enabled, scripts will not be automatically executed upon generation.",
"mssql.format.alignColumnDefinitionsInColumns": "Should column definitions be aligned?",
Expand Down
1 change: 1 addition & 0 deletions extensions/mssql/src/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export const configMaxRecentConnections = "maxRecentConnections";
export const configCopyRemoveNewLine = "copyRemoveNewLine";
export const configSplitPaneSelection = "splitPaneSelection";
export const configShowBatchTime = "showBatchTime";
export const configShowBatchMessages = "showBatchMessages";
export const configPreventAutoExecuteScript = "mssql.query.preventAutoExecuteScript";
export enum extConfigResultKeys {
Shortcuts = "shortcuts",
Expand Down
24 changes: 18 additions & 6 deletions extensions/mssql/src/controllers/queryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,25 @@ export default class QueryRunner {
let message = obj.message;
message.time = new Date(message.time).toLocaleTimeString();

// save the message into the batch summary so it can be restored on view refresh
if (message.batchId >= 0 && this._batchSetMessages[message.batchId] !== undefined) {
this._batchSetMessages[message.batchId].push(message);
}
// Check configuration to see if batch messages should be shown
let extConfig = this._vscodeWrapper.getConfiguration(
Constants.extensionConfigSectionName,
this.uri,
);
let showBatchMessages: boolean = extConfig.get(Constants.configShowBatchMessages) ?? true;

// Only show success messages if the configuration allows it
let shouldShowMessage = message.isError || showBatchMessages;

// Send the message to the results pane
this._messageEmitter.fire(message);
if (shouldShowMessage) {
// save the message into the batch summary so it can be restored on view refresh
if (message.batchId >= 0 && this._batchSetMessages[message.batchId] !== undefined) {
this._batchSetMessages[message.batchId].push(message);
}

// Send the message to the results pane
this._messageEmitter.fire(message);
}

// Set row count on status bar if there are no errors
if (!obj.message.isError) {
Expand Down
58 changes: 34 additions & 24 deletions extensions/mssql/src/models/sqlOutputContentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,31 +481,41 @@
);

const batchStartListener = queryRunner.onBatchStart(async (batch) => {
let time = new Date().toLocaleTimeString();
if (batch.executionElapsed && batch.executionEnd) {
time = new Date(batch.executionStart).toLocaleTimeString();
}

// Build a message for the selection and send the message
// from the webview
let message: IMessage = {
message: LocalizedConstants.runQueryBatchStartMessage,
selection: batch.selection,
isError: false,
time: time,
link: {
text: LocalizedConstants.runQueryBatchStartLine(
batch.selection.startLine + 1,
),
uri: queryRunner.uri,
},
};

const resultWebviewState = this._queryResultWebviewController.getQueryResultState(
queryRunner.uri,
// Check configuration to see if batch messages should be shown
let queryUri = queryRunner.uri;
let extConfig = this._vscodeWrapper.getConfiguration(
Constants.extensionConfigSectionName,
queryUri,
);
resultWebviewState.messages.push(message);
this.scheduleThrottledUpdate(queryRunner.uri);
let showBatchMessages: boolean = extConfig.get(Constants.configShowBatchMessages) ?? true;

Check failure on line 490 in extensions/mssql/src/models/sqlOutputContentProvider.ts

View workflow job for this annotation

GitHub Actions / build-and-test

Insert `␍⏎···················`
Copy link
Contributor

Choose a reason for hiding this comment

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

default value in the config definition should handle the ?? true case already


Check failure on line 491 in extensions/mssql/src/models/sqlOutputContentProvider.ts

View workflow job for this annotation

GitHub Actions / build-and-test

Delete `················`
if (showBatchMessages) {
Copy link
Contributor

@Benjin Benjin Dec 11, 2025

Choose a reason for hiding this comment

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

since checking this flag would be an early bail-out, it'd be a bit cleaner to do

if (showBatchMesssages === false) {
  return;
}

and leave the rest untouched

let time = new Date().toLocaleTimeString();
if (batch.executionElapsed && batch.executionEnd) {
time = new Date(batch.executionStart).toLocaleTimeString();
}

// Build a message for the selection and send the message
// from the webview
let message: IMessage = {
message: LocalizedConstants.runQueryBatchStartMessage,
selection: batch.selection,
isError: false,
time: time,
link: {
text: LocalizedConstants.runQueryBatchStartLine(
batch.selection.startLine + 1,
),
uri: queryRunner.uri,
},
};

const resultWebviewState = this._queryResultWebviewController.getQueryResultState(

Check failure on line 513 in extensions/mssql/src/models/sqlOutputContentProvider.ts

View workflow job for this annotation

GitHub Actions / build-and-test

Replace `·this._queryResultWebviewController.getQueryResultState(␍⏎························queryRunner.uri,␍⏎····················` with `␍⏎························this._queryResultWebviewController.getQueryResultState(queryRunner.uri`
queryRunner.uri,
);
resultWebviewState.messages.push(message);
this.scheduleThrottledUpdate(queryRunner.uri);
}
});

const onMessageListener = queryRunner.onMessage(async (message) => {
Expand Down
Loading