@@ -970,6 +970,7 @@ prompt::get_cmd_parameter_completion(textview_curses& tc,
970970 return this ->get_env_completion (str);
971971 }
972972
973+ auto str_as_path = lnav::filesystem::path_transcoder::from (str);
973974 std::set<std::string> poss_paths;
974975
975976 auto rp_opt = humanize::network::path::from_str (str);
@@ -996,8 +997,7 @@ prompt::get_cmd_parameter_completion(textview_curses& tc,
996997 poss_paths.emplace (poss_rpath);
997998 }
998999 } else {
999- auto str_as_path = lnav::filesystem::to_posix_path (str);
1000- auto parent = str_as_path.parent_path ();
1000+ auto parent = str_as_path.pt_path .parent_path ();
10011001 std::error_code ec;
10021002
10031003 log_trace (" not a remote path: %s" , str.c_str ());
@@ -1018,33 +1018,41 @@ prompt::get_cmd_parameter_completion(textview_curses& tc,
10181018 std::filesystem::directory_iterator (parent, ec))
10191019 {
10201020 auto path_str = entry.path ().string ();
1021+ log_debug (" entry: %s" , path_str.c_str ());
10211022 if (entry.is_directory ()) {
10221023 path_str.push_back (' /' );
10231024 } else if (ht->ht_format
10241025 == help_parameter_format_t ::HPF_DIRECTORY )
10251026 {
10261027 continue ;
10271028 }
1029+ path_str = str_as_path.to_native (path_str);
10281030 poss_paths.emplace (std::move (path_str));
10291031 }
10301032 if (ht->ht_format == help_parameter_format_t ::HPF_DIRECTORY
10311033 && !ec)
10321034 {
1033- poss_paths.emplace (parent.string () + " /" );
1035+ auto path_str = parent.string ();
1036+ path_str.push_back (' /' );
1037+ path_str = str_as_path.to_native (path_str);
1038+ poss_paths.emplace (path_str);
10341039 }
10351040 }
10361041
1037- retval = poss_paths | lnav::itertools::similar_to (str, 10 )
1038- | lnav::itertools::map ([&str](const auto & path_str) {
1039- auto escaped_path = shlex::escape (path_str);
1040- if (!endswith (path_str, " /" ) || path_str == str) {
1041- escaped_path.push_back (' ' );
1042- }
1043- return attr_line_t ()
1044- .append (path_str)
1045- .with_attr_for_all (
1046- SUBST_TEXT .value (escaped_path));
1047- });
1042+ retval
1043+ = poss_paths | lnav::itertools::similar_to (str, 10 )
1044+ | lnav::itertools::map ([&str](const std::string& path_str) {
1045+ auto escaped_path = shlex::escape (path_str);
1046+ if (path_str.find_last_of (" /\\ " ) == std::string::npos
1047+ || path_str == str)
1048+ {
1049+ escaped_path.push_back (' ' );
1050+ }
1051+ return attr_line_t ()
1052+ .append (path_str)
1053+ .with_attr_for_all (
1054+ SUBST_TEXT .value (escaped_path));
1055+ });
10481056 break ;
10491057 }
10501058 case help_parameter_format_t ::HPF_LOADED_FILE : {
0 commit comments