complete_filename: accept cursor_position as additional parameter

This commit is contained in:
Maxime Coste 2011-09-16 09:17:55 +00:00
parent 635e76eb4c
commit aeea1c610c
2 changed files with 9 additions and 6 deletions

View File

@ -7,16 +7,18 @@
namespace Kakoune
{
CandidateList complete_filename(const std::string& prefix)
CandidateList complete_filename(const std::string& prefix,
size_t cursor_pos)
{
size_t dir_end = prefix.find_last_of('/');
std::string real_prefix = prefix.substr(0, cursor_pos);
size_t dir_end = real_prefix.find_last_of('/');
std::string dirname = "./";
std::string fileprefix = prefix;
std::string fileprefix = real_prefix;
if (dir_end != std::string::npos)
{
dirname = prefix.substr(0, dir_end + 1);
fileprefix = prefix.substr(dir_end + 1, std::string::npos);
dirname = real_prefix.substr(0, dir_end + 1);
fileprefix = real_prefix.substr(dir_end + 1, std::string::npos);
}
auto dir = auto_raii(opendir(dirname.c_str()), closedir);

View File

@ -22,7 +22,8 @@ struct Completions
: start(start), end(end) {}
};
CandidateList complete_filename(const std::string& prefix);
CandidateList complete_filename(const std::string& prefix,
size_t cursor_pos = std::string::npos);
}
#endif // completion_hh_INCLUDED