summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-10-28 14:48:14 -0400
committerGitHub <noreply@github.com>2022-10-28 14:48:14 -0400
commit7c80f15020ba9c133fb17d908d8f3aeea4da71d2 (patch)
tree351c247d0726cb0ddd0edf08181e5292c75ea658
parentd1d42e6ba7324c97db8b488e41419564f29b475d (diff)
fix(lsp): correct `parameterNames.suppressWhenArgumentMatchesName` and `variableTypes.suppressWhenTypeMatchesName` (#16469)
Closes #16468
-rw-r--r--cli/lsp/config.rs6
-rw-r--r--cli/lsp/tsc.rs30
2 files changed, 29 insertions, 7 deletions
diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs
index 3c44ebe05..04a48435f 100644
--- a/cli/lsp/config.rs
+++ b/cli/lsp/config.rs
@@ -168,14 +168,14 @@ pub struct InlayHintsVarTypesOptions {
#[serde(default)]
pub enabled: bool,
#[serde(default = "is_true")]
- pub suppress_when_argument_matches_name: bool,
+ pub suppress_when_type_matches_name: bool,
}
impl Default for InlayHintsVarTypesOptions {
fn default() -> Self {
Self {
enabled: false,
- suppress_when_argument_matches_name: true,
+ suppress_when_type_matches_name: true,
}
}
}
@@ -685,7 +685,7 @@ mod tests {
parameter_types: InlayHintsParamTypesOptions { enabled: false },
variable_types: InlayHintsVarTypesOptions {
enabled: false,
- suppress_when_argument_matches_name: true
+ suppress_when_type_matches_name: true
},
property_declaration_types: InlayHintsPropDeclTypesOptions {
enabled: false
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index bed06e088..90658b8d7 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -3009,7 +3009,7 @@ impl From<&config::WorkspaceSettings> for UserPreferences {
(&inlay_hints.parameter_names.enabled).into(),
),
include_inlay_parameter_name_hints_when_argument_matches_name: Some(
- inlay_hints
+ !inlay_hints
.parameter_names
.suppress_when_argument_matches_name,
),
@@ -3020,9 +3020,7 @@ impl From<&config::WorkspaceSettings> for UserPreferences {
inlay_hints.variable_types.enabled,
),
include_inlay_variable_type_hints_when_type_matches_name: Some(
- inlay_hints
- .variable_types
- .suppress_when_argument_matches_name,
+ !inlay_hints.variable_types.suppress_when_type_matches_name,
),
include_inlay_property_declaration_type_hints: Some(
inlay_hints.property_declaration_types.enabled,
@@ -3447,6 +3445,7 @@ mod tests {
use super::*;
use crate::http_cache::HttpCache;
use crate::http_util::HeadersMap;
+ use crate::lsp::config::WorkspaceSettings;
use crate::lsp::documents::Documents;
use crate::lsp::documents::LanguageId;
use crate::lsp::text::LineIndex;
@@ -4306,4 +4305,27 @@ mod tests {
);
}
}
+
+ #[test]
+ fn include_supress_inlay_hit_settings() {
+ let mut settings = WorkspaceSettings::default();
+ settings
+ .inlay_hints
+ .parameter_names
+ .suppress_when_argument_matches_name = true;
+ settings
+ .inlay_hints
+ .variable_types
+ .suppress_when_type_matches_name = true;
+ let user_preferences: UserPreferences = (&settings).into();
+ assert_eq!(
+ user_preferences.include_inlay_variable_type_hints_when_type_matches_name,
+ Some(false)
+ );
+ assert_eq!(
+ user_preferences
+ .include_inlay_parameter_name_hints_when_argument_matches_name,
+ Some(false)
+ );
+ }
}