diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2011-12-22 13:44:04 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2011-12-22 13:44:04 +0000 |
| commit | aa1c4d64f9aa0f3506d4a324ffb03a6a77ad6a8e (patch) | |
| tree | 3c2e50c387b98b864be5058be7ae4d2aab4d5358 /src | |
| parent | 6fa5d809efabfae837a984bb1fb12746120ec4fb (diff) | |
Completions: complete_filename correctly support directories
Diffstat (limited to 'src')
| -rw-r--r-- | src/completion.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/completion.cc b/src/completion.cc index 936babaa..01ab56c7 100644 --- a/src/completion.cc +++ b/src/completion.cc @@ -14,11 +14,13 @@ CandidateList complete_filename(const std::string& prefix, std::string real_prefix = prefix.substr(0, cursor_pos); size_t dir_end = real_prefix.find_last_of('/'); std::string dirname = "./"; + std::string dirprefix; std::string fileprefix = real_prefix; if (dir_end != std::string::npos) { dirname = real_prefix.substr(0, dir_end + 1); + dirprefix = dirname; fileprefix = real_prefix.substr(dir_end + 1, std::string::npos); } @@ -29,7 +31,12 @@ CandidateList complete_filename(const std::string& prefix, { std::string filename = entry->d_name; if (filename.substr(0, fileprefix.length()) == fileprefix) - result.push_back(filename); + { + std::string name = dirprefix + filename; + if (entry->d_type == DT_DIR) + name += '/'; + result.push_back(name); + } } return result; } |
