Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
15 changes: 15 additions & 0 deletions Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,12 @@
"markdownDescription": "%c_cpp.configuration.hoverShowIntegralValuesInHexadecimal.markdownDescription%",
"scope": "resource"
},
"C_Cpp.hoverShowTypeSizeAndAlignment": {
"type": "boolean",
"default": true,
"markdownDescription": "%c_cpp.configuration.hoverShowTypeSizeAndAlignment.markdownDescription%",
"scope": "resource"
},
"C_Cpp.errorSquiggles": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -4011,6 +4017,11 @@
"title": "%c_cpp.command.toggleDimInactiveRegions.title%",
"category": "C/C++"
},
{
"command": "C_Cpp.ToggleTypeSizeAndAlignment",
"title": "%c_cpp.command.toggleTypeSizeAndAlignment.title%",
"category": "C/C++"
},
{
"command": "C_Cpp.FoldAllInactiveRegions",
"title": "%c_cpp.command.foldAllInactiveRegions.title%",
Expand Down Expand Up @@ -6574,6 +6585,10 @@
"command": "C_Cpp.ToggleDimInactiveRegions",
"when": "config.C_Cpp.intelliSenseEngine =~ /^[dD]efault$/"
},
{
"command": "C_Cpp.ToggleTypeSizeAndAlignment",
"when": "config.C_Cpp.intelliSenseEngine =~ /^[dD]efault$/"
},
{
"command": "C_Cpp.FoldAllInactiveRegions",
"when": "editorLangId =~ /^(c|(cuda-)?cpp)$/ && config.C_Cpp.intelliSenseEngine =~ /^[dD]efault$/ && config.C_Cpp.codeFolding =~ /^[eE]nabled$/"
Expand Down
7 changes: 7 additions & 0 deletions Extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"c_cpp.command.enableErrorSquiggles.title": "Enable Error Squiggles",
"c_cpp.command.disableErrorSquiggles.title": "Disable Error Squiggles",
"c_cpp.command.toggleDimInactiveRegions.title": "Toggle Inactive Region Colorization",
"c_cpp.command.toggleTypeSizeAndAlignment.title": "Toggle Type Size and Alignment in Hovers",
"c_cpp.command.foldAllInactiveRegions.title": "Fold All Inactive Regions",
"c_cpp.command.unfoldAllInactiveRegions.title": "Unfold All Inactive Regions",
"c_cpp.command.resetDatabase.title": "Reset IntelliSense Database",
Expand Down Expand Up @@ -779,6 +780,12 @@
"Markdown text between `` should not be translated or localized (it represents literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
]
},
"c_cpp.configuration.hoverShowTypeSizeAndAlignment.markdownDescription": {
"message": "Displays the size and alignment of types in IntelliSense hovers. This setting only applies if `#C_Cpp.intelliSenseEngine#` is set to `default`.",
"comment": [
"Markdown text between `` should not be translated or localized (it represents literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
]
},
"c_cpp.configuration.vcpkg.enabled.markdownDescription": {
"message": "Enable integration services for the [vcpkg dependency manager](https://aka.ms/vcpkg/).",
"comment": [
Expand Down
1 change: 1 addition & 0 deletions Extension/src/LanguageServer/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,7 @@ export class DefaultClient implements Client {
markdownInComments: settings.markdownInComments,
hover: settings.hover,
hoverShowIntegralValuesInHexadecimal: settings.hoverShowIntegralValuesInHexadecimal,
hoverShowTypeSizeAndAlignment: settings.hoverShowTypeSizeAndAlignment,
vcFormatIndentBraces: settings.vcFormatIndentBraces,
vcFormatIndentMultiLineRelativeTo: settings.vcFormatIndentMultiLineRelativeTo,
vcFormatIndentWithinParentheses: settings.vcFormatIndentWithinParentheses,
Expand Down
13 changes: 10 additions & 3 deletions Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ export async function registerCommands(enabled: boolean): Promise<void> {
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.EnableErrorSquiggles', enabled ? onEnableSquiggles : onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.DisableErrorSquiggles', enabled ? onDisableSquiggles : onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.ToggleDimInactiveRegions', enabled ? onToggleDimInactiveRegions : onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.ToggleTypeSizeAndAlignment', enabled ? onToggleTypeSizeAndAlignment : onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.FoldAllInactiveRegions', enabled ? onFoldAllInactiveRegions : onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.UnfoldAllInactiveRegions', enabled ? onUnfoldAllInactiveRegions : onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.PauseParsing', enabled ? onPauseParsing : onDisabledCommand));
Expand Down Expand Up @@ -912,19 +913,25 @@ async function onAddToIncludePath(path: string): Promise<void> {
function onEnableSquiggles(): void {
// This only applies to the active client.
const settings: CppSettings = new CppSettings(clients.ActiveClient.RootUri);
settings.update<string>("errorSquiggles", "enabled");
void settings.update<string>("errorSquiggles", "enabled");
}

function onDisableSquiggles(): void {
// This only applies to the active client.
const settings: CppSettings = new CppSettings(clients.ActiveClient.RootUri);
settings.update<string>("errorSquiggles", "disabled");
void settings.update<string>("errorSquiggles", "disabled");
}

function onToggleDimInactiveRegions(): void {
// This only applies to the active client.
const settings: CppSettings = new CppSettings(clients.ActiveClient.RootUri);
settings.update<boolean>("dimInactiveRegions", !settings.dimInactiveRegions);
void settings.update<boolean>("dimInactiveRegions", !settings.dimInactiveRegions);
}

function onToggleTypeSizeAndAlignment(): Thenable<void> {
// This only applies to the active client.
const settings: CppSettings = new CppSettings(clients.ActiveClient.RootUri);
return settings.update<boolean>("hoverShowTypeSizeAndAlignment", !settings.hoverShowTypeSizeAndAlignment);
Comment thread
Colengms marked this conversation as resolved.
Resolved
}

function onFoldAllInactiveRegions(): Promise<void> {
Expand Down
6 changes: 4 additions & 2 deletions Extension/src/LanguageServer/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export interface WorkspaceFolderSettingsParams {
clangTidyChecksDisabled: string[] | undefined;
hover: string;
hoverShowIntegralValuesInHexadecimal: boolean;
hoverShowTypeSizeAndAlignment: boolean;
markdownInComments: string;
vcFormatIndentBraces: boolean;
vcFormatIndentMultiLineRelativeTo: string;
Expand Down Expand Up @@ -480,6 +481,7 @@ export class CppSettings extends Settings {
public get doxygenSectionTags(): string[] { return this.getAsArrayOfStrings("doxygen.sectionTags"); }
public get hover(): string { return this.getAsString("hover"); }
public get hoverShowIntegralValuesInHexadecimal(): boolean { return this.getAsBoolean("hoverShowIntegralValuesInHexadecimal"); }
public get hoverShowTypeSizeAndAlignment(): boolean { return this.getAsBoolean("hoverShowTypeSizeAndAlignment"); }
public get markdownInComments(): string { return this.getAsString("markdownInComments"); }
public get legacyCompilerArgsBehavior(): boolean { return this.getAsBoolean("legacyCompilerArgsBehavior"); }
public get inlayHintsAutoDeclarationTypes(): boolean { return this.getAsBoolean("inlayHints.autoDeclarationTypes.enabled"); }
Expand Down Expand Up @@ -767,8 +769,8 @@ export class CppSettings extends Settings {
void super.Section.update(name, value?.toLowerCase() === value1.toLowerCase() ? value2 : value1, getTarget());
}

public update<T>(name: string, value: T): void {
void super.Section.update(name, value);
public update<T>(name: string, value: T): Thenable<void> {
Comment thread
Colengms marked this conversation as resolved.
Resolved
return super.Section.update(name, value);
}

public populateEditorConfig(document: vscode.TextDocument): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,23 @@ suite("[Quick info test]", function(): void {
const originalHover: string | undefined = configuration.inspect<string>("hover")?.workspaceFolderValue;
const originalShowIntegralValuesInHexadecimal: boolean | undefined =
configuration.inspect<boolean>("hoverShowIntegralValuesInHexadecimal")?.workspaceFolderValue;
const originalShowTypeSizeAndAlignment: boolean | undefined =
configuration.inspect<boolean>("hoverShowTypeSizeAndAlignment")?.workspaceFolderValue;

try {
await configuration.update("hover", "disabled", vscode.ConfigurationTarget.WorkspaceFolder);
await configuration.update("hoverShowIntegralValuesInHexadecimal", true, vscode.ConfigurationTarget.WorkspaceFolder);
await configuration.update("hoverShowTypeSizeAndAlignment", false, vscode.ConfigurationTarget.WorkspaceFolder);

const settings: CppSettings = new CppSettings(fileUri);
assert.strictEqual(settings.hover, "disabled");
assert.strictEqual(settings.hoverShowIntegralValuesInHexadecimal, true);
assert.strictEqual(settings.hoverShowTypeSizeAndAlignment, false);
} finally {
await configuration.update(
"hoverShowTypeSizeAndAlignment",
originalShowTypeSizeAndAlignment,
vscode.ConfigurationTarget.WorkspaceFolder);
await configuration.update(
"hoverShowIntegralValuesInHexadecimal",
originalShowIntegralValuesInHexadecimal,
Expand All @@ -128,6 +136,27 @@ suite("[Quick info test]", function(): void {
}
});

test("[Toggle type size and alignment command]", async () => {
const configuration: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("C_Cpp", fileUri);
const originalShowTypeSizeAndAlignment: boolean | undefined =
configuration.inspect<boolean>("hoverShowTypeSizeAndAlignment")?.workspaceFolderValue;

try {
await configuration.update("hoverShowTypeSizeAndAlignment", true, vscode.ConfigurationTarget.WorkspaceFolder);

await vscode.commands.executeCommand("C_Cpp.ToggleTypeSizeAndAlignment");
assert.strictEqual(configuration.inspect<boolean>("hoverShowTypeSizeAndAlignment")?.workspaceFolderValue, false);

await vscode.commands.executeCommand("C_Cpp.ToggleTypeSizeAndAlignment");
assert.strictEqual(configuration.inspect<boolean>("hoverShowTypeSizeAndAlignment")?.workspaceFolderValue, true);
Comment thread
Colengms marked this conversation as resolved.
Resolved
} finally {
await configuration.update(
"hoverShowTypeSizeAndAlignment",
originalShowTypeSizeAndAlignment,
vscode.ConfigurationTarget.WorkspaceFolder);
}
});

test("[Folder hexadecimal setting preserves global disabled hover]", async () => {
const configuration: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("C_Cpp", fileUri);
const originalGlobalHover: string | undefined = configuration.inspect<string>("hover")?.globalValue;
Expand Down
Loading