Skip to content

Add max length configuration for connection info in status bar #19276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
3 changes: 3 additions & 0 deletions localization/xliff/vscode-mssql.xlf
Original file line number Diff line number Diff line change
@@ -2489,6 +2489,9 @@
<trans-unit id="mssql.connectionGroup.description">
<source xml:lang="en">The description of the connection group.</source>
</trans-unit>
<trans-unit id="mssql.statusBar.connectionInfoMaxLength.description">
<source xml:lang="en">The maximum number of characters to display for the connection info in the status bar. Set to -1 for no limit.</source>
</trans-unit>
<trans-unit id="mssql.maxRecentConnections">
<source xml:lang="en">The maximum number of recently used connections to store in the connection list.</source>
</trans-unit>
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1718,6 +1718,11 @@
"default": 45,
"minimum": 1,
"description": "%mssql.objectExplorer.expandTimeout%"
},
"mssql.statusBar.connectionInfoMaxLength": {
"type": "number",
"default": 50,
"description": "%mssql.statusBar.connectionInfoMaxLength.description%"
}
}
},
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
@@ -199,5 +199,6 @@
"mssql.walkthroughs.nextSteps.viewQueryPlan.altText": "Query plan visualization",
"mssql.walkthroughs.nextSteps.objectExplorerFilters.title": "Filter your Object Explorer Tree",
"mssql.walkthroughs.nextSteps.objectExplorerFilters.description": "Only see the database objects that matter most to you by applying filters to the Object Explorer tree.\nStart by clicking the filter button next to most folders in the Connections view.",
"mssql.walkthroughs.nextSteps.objectExplorerFilters.altText": "Object Explorer filters"
"mssql.walkthroughs.nextSteps.objectExplorerFilters.altText": "Object Explorer filters",
"mssql.statusBar.connectionInfoMaxLength.description": "The maximum number of characters to display for the connection info in the status bar. Set to -1 for no limit."
}
1 change: 1 addition & 0 deletions src/constants/constants.ts
Original file line number Diff line number Diff line change
@@ -196,6 +196,7 @@ export const configOpenQueryResultsInTabByDefaultDoNotShowPrompt =
"mssql.openQueryResultsInTabByDefaultDoNotShowPrompt";
export const configAutoColumnSizing = "resultsGrid.autoSizeColumns";
export const configAutoDisableNonTSqlLanguageService = "mssql.autoDisableNonTSqlLanguageService";
export const configStatusBarConnectionInfoMaxLength = "statusBar.connectionInfoMaxLength";

// ToolsService Constants
export const serviceInstallingTo = "Installing SQL tools service to";
15 changes: 13 additions & 2 deletions src/models/connectionInfo.ts
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import * as LocalizedConstants from "../constants/locConstants";
import { EncryptOptions } from "../models/interfaces";
import * as Interfaces from "./interfaces";
import * as Utils from "./utils";
import * as vscode from "vscode";

/**
* Sets sensible defaults for key connection properties, especially
@@ -149,9 +150,19 @@ export function getConnectionDisplayString(creds: IConnectionInfo): string {
let user: string = getUserNameOrDomainLogin(creds);
text = appendIfNotEmpty(text, user);

let statusBarConnectionInfoMaxLength: number = vscode.workspace
.getConfiguration(Constants.extensionConfigSectionName)
.get(Constants.configStatusBarConnectionInfoMaxLength);

statusBarConnectionInfoMaxLength ||= Constants.maxDisplayedStatusTextLength;

// Limit the maximum length of displayed text
if (text && text.length > Constants.maxDisplayedStatusTextLength) {
text = text.substr(0, Constants.maxDisplayedStatusTextLength);
if (
statusBarConnectionInfoMaxLength >= 0 &&
text &&
text.length > statusBarConnectionInfoMaxLength
) {
text = text.substr(0, statusBarConnectionInfoMaxLength);
text += " \u2026"; // Ellipsis character (...)
}