Skip to content

Commit d2d5203

Browse files
authored
[clangd] Consistent precedence between --header-insertion and HeaderInsertion (#146235)
In PR #128503, the CLI option would take precedence over the config option only if it was set to `never`. This commit ensures the CLI option always takes precedence over the config option.
1 parent f5ed863 commit d2d5203

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

clang-tools-extra/clangd/tool/ClangdMain.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,6 @@ class FlagsConfigProvider : public config::Provider {
668668
std::optional<Config::ExternalIndexSpec> IndexSpec;
669669
std::optional<Config::BackgroundPolicy> BGPolicy;
670670
std::optional<Config::ArgumentListsPolicy> ArgumentLists;
671-
std::optional<Config::HeaderInsertionPolicy> HeaderInsertionPolicy;
672671

673672
// If --compile-commands-dir arg was invoked, check value and override
674673
// default path.
@@ -713,11 +712,6 @@ class FlagsConfigProvider : public config::Provider {
713712
BGPolicy = Config::BackgroundPolicy::Skip;
714713
}
715714

716-
// If CLI has set never, use that regardless of what the config files have
717-
if (HeaderInsertion == Config::HeaderInsertionPolicy::NeverInsert) {
718-
HeaderInsertionPolicy = Config::HeaderInsertionPolicy::NeverInsert;
719-
}
720-
721715
if (std::optional<bool> Enable = shouldEnableFunctionArgSnippets()) {
722716
ArgumentLists = *Enable ? Config::ArgumentListsPolicy::FullPlaceholders
723717
: Config::ArgumentListsPolicy::Delimiters;
@@ -732,8 +726,8 @@ class FlagsConfigProvider : public config::Provider {
732726
C.Index.Background = *BGPolicy;
733727
if (ArgumentLists)
734728
C.Completion.ArgumentLists = *ArgumentLists;
735-
if (HeaderInsertionPolicy)
736-
C.Completion.HeaderInsertion = *HeaderInsertionPolicy;
729+
if (HeaderInsertion.getNumOccurrences())
730+
C.Completion.HeaderInsertion = HeaderInsertion;
737731
if (AllScopesCompletion.getNumOccurrences())
738732
C.Completion.AllScopes = AllScopesCompletion;
739733

0 commit comments

Comments
 (0)