From 02b7786bcd175637848d02f5ff800247e0403760 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 7 Aug 2012 00:16:51 +0200 Subject: [PATCH] fix complete_filename --- src/completion.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/completion.cc b/src/completion.cc index 09744f27..1d2a5e86 100644 --- a/src/completion.cc +++ b/src/completion.cc @@ -14,16 +14,21 @@ CandidateList complete_filename(const Context& context, size_t cursor_pos) { String real_prefix = prefix.substr(0, cursor_pos); - auto dir_end = std::find(real_prefix.begin(), real_prefix.end(), '/'); String dirname = "./"; String dirprefix; String fileprefix = real_prefix; - if (dir_end != real_prefix.end()) + size_t dir_end = -1; + for (size_t i = 0; i < real_prefix.length(); ++i) { - dirname = String(real_prefix.begin(), dir_end + 1); + if (real_prefix[i] == '/') + dir_end = i; + } + if (dir_end != -1) + { + dirname = real_prefix.substr(0, dir_end + 1); dirprefix = dirname; - fileprefix = String(dir_end + 1, real_prefix.end()); + fileprefix = real_prefix.substr(dir_end + 1); } DIR* dir = opendir(dirname.c_str());