diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-08-07 00:16:51 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-08-07 00:16:51 +0200 |
| commit | 02b7786bcd175637848d02f5ff800247e0403760 (patch) | |
| tree | 6456d195f7e5b7086236cb7576ef1e65c5db3f7b /src | |
| parent | b69134c36fb1585404776c668ad6d7d72975a210 (diff) | |
fix complete_filename
Diffstat (limited to 'src')
| -rw-r--r-- | src/completion.cc | 13 |
1 files 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()); |
