From 14650ddfb8d31a0e075b4684e8c1ebc9976319bc Mon Sep 17 00:00:00 2001 From: Jonathan Hale Date: Thu, 18 Jan 2018 10:09:53 +0100 Subject: [vkpkg] Fix edit command not considering EDITOR environment variable (#2597) * [vkpkg] Fix edit command not considering EDITOR environment variable Signed-off-by: Squareys * [vcpkg-edit] Reformat and improve code consistency --- toolsrc/src/vcpkg/commands.edit.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'toolsrc/src') 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 candidate_paths; - const std::vector 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."); -- cgit v1.2.3