Show Trust server certificate on dialog and fix bool select-box defaults (#21020)

This commit is contained in:
Cheena Malhotra
2022-10-28 19:43:43 -07:00
committed by GitHub
parent 998b528680
commit f3fcaa21da
9 changed files with 91 additions and 18 deletions

View File

@@ -19,3 +19,40 @@ export function getSqlConfigValue<T>(workspaceConfigService: IConfigurationServi
let config = workspaceConfigService.getValue<{ [key: string]: any }>(ConnectionConstants.sqlConfigSectionName);
return config ? config[configName] : undefined;
}
/**
* Wraps provided string using \n that qualifies as line break to wrap text in title attributes (tooltips).
* @param str string to be wrapped
* @param maxWidth max width to be allowed for wrapped text
* @returns wrapped string
*/
export function wrapStringWithNewLine(str: string | undefined, maxWidth: number): string | undefined {
if (!str) {
return str;
}
let newLineStr = `\n`;
let res = '';
while (str.length > maxWidth) {
let found = false;
// Inserts new line at first whitespace of the line
for (let i = maxWidth - 1; i >= 0; i--) {
if (testWhitespace(str.charAt(i))) {
res = res + [str.slice(0, i), newLineStr].join('');
str = str.slice(i + 1);
found = true;
break;
}
}
// Inserts new line at maxWidth position, the word is too long to wrap
if (!found) {
res += [str.slice(0, maxWidth), newLineStr].join('');
str = str.slice(maxWidth);
}
}
return res + str;
}
function testWhitespace(x: string) {
var white = new RegExp(/^\s$/);
return white.test(x.charAt(0));
}