complete_filename: accept cursor_position as additional parameter
This commit is contained in:
parent
635e76eb4c
commit
aeea1c610c
|
@ -7,16 +7,18 @@
|
||||||
namespace Kakoune
|
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 dirname = "./";
|
||||||
std::string fileprefix = prefix;
|
std::string fileprefix = real_prefix;
|
||||||
|
|
||||||
if (dir_end != std::string::npos)
|
if (dir_end != std::string::npos)
|
||||||
{
|
{
|
||||||
dirname = prefix.substr(0, dir_end + 1);
|
dirname = real_prefix.substr(0, dir_end + 1);
|
||||||
fileprefix = prefix.substr(dir_end + 1, std::string::npos);
|
fileprefix = real_prefix.substr(dir_end + 1, std::string::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto dir = auto_raii(opendir(dirname.c_str()), closedir);
|
auto dir = auto_raii(opendir(dirname.c_str()), closedir);
|
||||||
|
|
|
@ -22,7 +22,8 @@ struct Completions
|
||||||
: start(start), end(end) {}
|
: 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
|
#endif // completion_hh_INCLUDED
|
||||||
|
|
Loading…
Reference in New Issue
Block a user