All files / utilities config-scope.ts

100% Statements 13/13
100% Branches 6/6
100% Functions 3/3
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41          2x 2x 2x               2x 3x   1x   1x   1x                 2x 3x   1x   1x   1x    
/**
 * List of configuration targets supported by Mentor. The values correspond to
 * the VS Code ConfigurationTarget enum (https://code.visualstudio.com/api/references/vscode-api#ConfigurationTarget).
 * But we define our own enum here to avoid a dependency on the 'vscode' module for webviews and LSP processes.
 */
export enum ConfigurationScope {
	User = 1,
	Workspace = 2
}
 
/**
 * Get a label for a configuration scope.
 * @param scope A configuration scope value.
 * @returns A string label for the configuration scope.
 */
export const getConfigurationScopeLabel = (scope: ConfigurationScope) => {
	switch (scope) {
		case ConfigurationScope.User:
			return 'User';
		case ConfigurationScope.Workspace:
			return 'Workspace';
		default:
			return 'Unknown';
	}
};
 
/**
 * Get a description for a configuration scope.
 * @param scope A configuration scope value.
 * @returns A string description of the configuration scope.
 */
export const getConfigurationScopeDescription = (scope: ConfigurationScope) => {
	switch (scope) {
		case ConfigurationScope.User:
			return 'The settings will be available in all Visual Studio Code sessions on your local machine.';
		case ConfigurationScope.Workspace:
			return 'The settings are stored in the .vscode folder. All connection parameters except secrets can be shared with version control.';
		default:
			return '';
	}
}