From 92bd4755bfef6c0085b4711cc2ff64a904739bd4 Mon Sep 17 00:00:00 2001 From: taynpg Date: Tue, 25 Feb 2025 17:45:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20filecomplete.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- filecomplete.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/filecomplete.cpp b/filecomplete.cpp index b04758f..140d546 100644 --- a/filecomplete.cpp +++ b/filecomplete.cpp @@ -661,8 +661,9 @@ char* fc_readline() append_his(main_buf); if (need_turn) { std::string rep(main_buf); - if (rep.find("~") == 0) { - rep = get_home() + rep.substr(1, rep.size() - 1); + auto spos = rep.find("~"); + 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::snprintf(main_buf, buf_size, "%s", rep.c_str()); }