diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-04-14 01:17:09 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-04-14 01:17:09 +0000 |
| commit | 93379384036dadada06139245d1e4eca13cabebd (patch) | |
| tree | 0f5475fd2c7fc212982d881b67444b20a0f8f809 /src/completion.cc | |
| parent | af5c528f043f663b94ce197b0c70ddb3da9224e8 (diff) | |
replace std::string references with String
Diffstat (limited to 'src/completion.cc')
| -rw-r--r-- | src/completion.cc | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/completion.cc b/src/completion.cc index 17482d14..8b1e8757 100644 --- a/src/completion.cc +++ b/src/completion.cc @@ -9,20 +9,20 @@ namespace Kakoune { -CandidateList complete_filename(const std::string& prefix, +CandidateList complete_filename(const String& prefix, size_t cursor_pos) { - 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; + 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 != std::string::npos) + if (dir_end != real_prefix.end()) { - dirname = real_prefix.substr(0, dir_end + 1); + dirname = String(real_prefix.begin(), dir_end + 1); dirprefix = dirname; - fileprefix = real_prefix.substr(dir_end + 1, std::string::npos); + fileprefix = String(dir_end + 1, real_prefix.end()); } auto dir = auto_raii(opendir(dirname.c_str()), closedir); @@ -33,13 +33,13 @@ CandidateList complete_filename(const std::string& prefix, while (dirent* entry = readdir(dir)) { - std::string filename = entry->d_name; + String filename = entry->d_name; if (filename.empty()) continue; if (filename.substr(0, fileprefix.length()) == fileprefix) { - std::string name = dirprefix + filename; + String name = dirprefix + filename; if (entry->d_type == DT_DIR) name += '/'; if (fileprefix.length() or filename[0] != '.') |
