diff options
| author | Jonathan Hale <Squareys@googlemail.com> | 2018-01-18 10:09:53 +0100 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2018-01-18 01:09:53 -0800 |
| commit | 14650ddfb8d31a0e075b4684e8c1ebc9976319bc (patch) | |
| tree | d3c0105d4742aeaca9d94d2760091274fd9f7cea /toolsrc/src | |
| parent | 27188d3b1e9fca6b5794d049bde7edd5e8126dd2 (diff) | |
| download | vcpkg-14650ddfb8d31a0e075b4684e8c1ebc9976319bc.tar.gz vcpkg-14650ddfb8d31a0e075b4684e8c1ebc9976319bc.zip | |
[vkpkg] Fix edit command not considering EDITOR environment variable (#2597)
* [vkpkg] Fix edit command not considering EDITOR environment variable
Signed-off-by: Squareys <squareys@googlemail.com>
* [vcpkg-edit] Reformat and improve code consistency
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/vcpkg/commands.edit.cpp | 12 |
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."); |
