Add setting to hide leading underscores for inlay hints. (#9500)
* Add setting to hide leading underscores for inlay hints.
This commit is contained in:
Родитель
a8e6695b55
Коммит
6f3ae65833
|
@ -2235,6 +2235,12 @@
|
|||
"markdownDescription": "%c_cpp.configuration.inlayHints.parameterNames.suppressWhenArgumentContainsName.markdownDescription%",
|
||||
"scope": "application"
|
||||
},
|
||||
"C_Cpp.inlayHints.parameterNames.hideLeadingUnderscores": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"markdownDescription": "%c_cpp.configuration.inlayHints.parameterNames.hideLeadingUnderscores.markdownDescription%",
|
||||
"scope": "application"
|
||||
},
|
||||
"C_Cpp.inlayHints.referenceOperator.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
|
|
|
@ -169,6 +169,7 @@
|
|||
"c_cpp.configuration.inlayHints.autoDeclarationTypes.enabled.markdownDescription": { "message": "Display inlay hints for deduced type when `auto` is used in a declaration:\n```cpp \n\n auto index /* : int */ = 0;\n```", "comment": [ "Markdown text between `` and the text inside ``` block is code and should not be localized." ] },
|
||||
"c_cpp.configuration.inlayHints.autoDeclarationTypes.showOnLeft.markdownDescription": { "message": "Display inlay hints for deduced type when `auto` is used in a declaration on the left of the identifier:\n```cpp \n\n auto /* int */ index = 0;\n```", "comment": [ "Markdown text between `` and the text inside ``` block is code and should not be localized." ] },
|
||||
"c_cpp.configuration.inlayHints.parameterNames.enabled.markdownDescription": { "message": "Display inlay hints for parameter names:\n```cpp \n\n int a = getArea(/* width: */ x, /* height: */ y);\n```", "comment": [ "Markdown text between `` and the text inside ``` block is code and should not be localized." ] },
|
||||
"c_cpp.configuration.inlayHints.parameterNames.hideLeadingUnderscores.markdownDescription": { "message": "Hide leading `_` in parameter name hints.", "comment": [ "Markdown text between `` is code and should not be localized." ] },
|
||||
"c_cpp.configuration.inlayHints.parameterNames.suppressWhenArgumentContainsName.markdownDescription": { "message": "Suppress parameter name hints when the argument text or inline comment contains the parameter name:\n```cpp \n\n int a = getArea(width, /* height: */ y);\n```", "comment": [ "Markdown text between `` and the text inside ``` block is code and should not be localized." ] },
|
||||
"c_cpp.configuration.inlayHints.referenceOperator.enabled.markdownDescription": { "message": "Display the inlay hint reference operator `&` for parameters passed by non-const reference:\n```cpp \n\n swap(/* &first: */ str1, /* &last: */ str2);\n```", "comment": [ "Markdown text between `` and the text inside ``` block is code and should not be localized." ] },
|
||||
"c_cpp.configuration.inlayHints.referenceOperator.showSpace.markdownDescription": { "message": "Controls whether a space is shown after `&` for parameters passed by non-const reference:\n```cpp \n\n swap(/* & first: */ str1, /* & last: */ str2);\n```", "comment": [ "Markdown text between `` and the text inside ``` block is code and should not be localized." ] },
|
||||
|
|
|
@ -104,6 +104,18 @@ export class InlayHintsProvider implements vscode.InlayHintsProvider {
|
|||
let paramHintLabel: string = "";
|
||||
if (settings.inlayHintsParameterNames) {
|
||||
paramHintLabel = (settings.inlayHintsParameterNamesSuppressName && hint.hasParamName) ? "" : hint.label;
|
||||
if (paramHintLabel !== "" && settings.inlayHintsParameterNamesHideLeadingUnderscores) {
|
||||
let nonUnderscoreIndex: number = 0;
|
||||
for (let i: number = 0; i < paramHintLabel.length; ++i) {
|
||||
if (paramHintLabel[i] !== '_') {
|
||||
nonUnderscoreIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nonUnderscoreIndex > 0) {
|
||||
paramHintLabel = paramHintLabel.substring(nonUnderscoreIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
let refOperatorString: string = "";
|
||||
if (settings.inlayHintsReferenceOperator && hint.isValueRef) {
|
||||
|
|
|
@ -268,6 +268,10 @@ export class CppSettings extends Settings {
|
|||
return super.Section.get<boolean>("inlayHints.parameterNames.suppressWhenArgumentContainsName") === true;
|
||||
}
|
||||
|
||||
public get inlayHintsParameterNamesHideLeadingUnderscores(): boolean {
|
||||
return super.Section.get<boolean>("inlayHints.parameterNames.hideLeadingUnderscores") === true;
|
||||
}
|
||||
|
||||
public get inlayHintsReferenceOperator(): boolean {
|
||||
return super.Section.get<boolean>("inlayHints.referenceOperator.enabled") === true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче