更新 filecomplete.cpp

This commit is contained in:
taynpg 2025-02-25 17:45:15 +08:00
parent 16633d9d9a
commit 92bd4755bf

View File

@ -661,8 +661,9 @@ char* fc_readline()
append_his(main_buf); append_his(main_buf);
if (need_turn) { if (need_turn) {
std::string rep(main_buf); std::string rep(main_buf);
if (rep.find("~") == 0) { auto spos = rep.find("~");
rep = get_home() + rep.substr(1, rep.size() - 1); if (spos != std::string::npos) {
rep = rep.substr(0, spos) + get_home() + rep.substr(spos + 1, rep.size() - spos);
std::memset(main_buf, 0x0, buf_size); std::memset(main_buf, 0x0, buf_size);
std::snprintf(main_buf, buf_size, "%s", rep.c_str()); std::snprintf(main_buf, buf_size, "%s", rep.c_str());
} }