From b47df2a30482e4588ec4b715502065f34b7bbed0 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 26 May 2023 10:14:35 +0200 Subject: [PATCH] Copilot: Register settings aspects more directly Also simplify a search. Change-Id: I2ba511ca3250c624fb7dbc2b44f845a5757e72ce Reviewed-by: Marcus Tillmanns --- src/plugins/copilot/copilotsettings.cpp | 7 +------ src/plugins/copilot/copilotsettings.h | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/plugins/copilot/copilotsettings.cpp b/src/plugins/copilot/copilotsettings.cpp index 202da82488f..8c701448eb1 100644 --- a/src/plugins/copilot/copilotsettings.cpp +++ b/src/plugins/copilot/copilotsettings.cpp @@ -32,11 +32,8 @@ CopilotSettings::CopilotSettings() FilePath::fromUserInput( "~/AppData/Local/nvim/pack/github/start/copilot.vim/copilot/dist/agent.js")}; - const FilePath distFromVim = Utils::findOrDefault(searchDirs, [](const FilePath &fp) { - return fp.exists(); - }); + const FilePath distFromVim = Utils::findOrDefault(searchDirs, &FilePath::exists); - registerAspect(&nodeJsPath); nodeJsPath.setExpectedKind(PathChooser::ExistingCommand); nodeJsPath.setDefaultFilePath(nodeFromPath); nodeJsPath.setSettingsKey("Copilot.NodeJsPath"); @@ -47,7 +44,6 @@ CopilotSettings::CopilotSettings() Tr::tr("Select path to node.js executable. See https://nodejs.org/de/download/" "for installation instructions.")); - registerAspect(&distPath); distPath.setExpectedKind(PathChooser::File); distPath.setDefaultFilePath(distFromVim); distPath.setSettingsKey("Copilot.DistPath"); @@ -58,7 +54,6 @@ CopilotSettings::CopilotSettings() "Select path to agent.js in copilot neovim plugin. See " "https://github.com/github/copilot.vim#getting-started for installation instructions.")); - registerAspect(&autoComplete); autoComplete.setDisplayName(Tr::tr("Auto Complete")); autoComplete.setLabelText(Tr::tr("Request completions automatically")); autoComplete.setDefaultValue(true); diff --git a/src/plugins/copilot/copilotsettings.h b/src/plugins/copilot/copilotsettings.h index 23370948765..ea3ac7520f5 100644 --- a/src/plugins/copilot/copilotsettings.h +++ b/src/plugins/copilot/copilotsettings.h @@ -14,9 +14,9 @@ public: static CopilotSettings &instance(); - Utils::FilePathAspect nodeJsPath; - Utils::FilePathAspect distPath; - Utils::BoolAspect autoComplete; + Utils::FilePathAspect nodeJsPath{this}; + Utils::FilePathAspect distPath{this}; + Utils::BoolAspect autoComplete{this}; }; } // namespace Copilot