aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toolsrc/src/vcpkg/commands.edit.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/toolsrc/src/vcpkg/commands.edit.cpp b/toolsrc/src/vcpkg/commands.edit.cpp
index 3e5d08956..41f261a53 100644
--- a/toolsrc/src/vcpkg/commands.edit.cpp
+++ b/toolsrc/src/vcpkg/commands.edit.cpp
@@ -68,8 +68,11 @@ namespace vcpkg::Commands::Edit
Checks::check_exit(VCPKG_LINE_INFO, fs.is_directory(portpath), R"(Could not find port named "%s")", port_name);
std::vector<fs::path> candidate_paths;
- const std::vector<fs::path> from_path = Files::find_from_PATH("EDITOR");
- candidate_paths.insert(candidate_paths.end(), from_path.cbegin(), from_path.cend());
+ auto maybe_editor_path = System::get_environment_variable("EDITOR");
+ if (auto editor_path = maybe_editor_path.get())
+ {
+ candidate_paths.emplace_back(*editor_path);
+ }
candidate_paths.push_back(System::get_program_files_platform_bitness() / VS_CODE_INSIDERS);
candidate_paths.push_back(System::get_program_files_32_bit() / VS_CODE_INSIDERS);
candidate_paths.push_back(System::get_program_files_platform_bitness() / VS_CODE);
@@ -81,8 +84,9 @@ namespace vcpkg::Commands::Edit
auto it = Util::find_if(candidate_paths, [&](const fs::path& p) { return fs.exists(p); });
if (it == candidate_paths.cend())
{
- System::println(System::Color::error,
- "Error: Visual Studio Code was not found and the environment variable EDITOR is not set.");
+ System::println(
+ System::Color::error,
+ "Error: Visual Studio Code was not found and the environment variable EDITOR is not set or invalid.");
System::println("The following paths were examined:");
Files::print_paths(candidate_paths);
System::println("You can also set the environmental variable EDITOR to your editor of choice.");