1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-06-29 01:56:44 +02:00

sort directories and skip special symbols for path autocomplete

This commit is contained in:
Jfreegman
2014-07-23 18:34:32 -04:00
parent 8660047ec1
commit 8d8df585ad
3 changed files with 8 additions and 5 deletions

View File

@ -273,7 +273,8 @@ int dir_match(ToxWindow *self, Tox *m, wchar_t *line)
int dircount = 0;
while ((entry = readdir(dp)) && dircount < MAX_DIRS) {
if (strncmp(entry->d_name, b_name, b_name_len) == 0) {
if (strncmp(entry->d_name, b_name, b_name_len) == 0
&& strcmp(".", entry->d_name) && strcmp("..", entry->d_name)) {
snprintf(dirnames[dircount], sizeof(dirnames[dircount]), "%s", entry->d_name);
++dircount;
}
@ -282,8 +283,10 @@ int dir_match(ToxWindow *self, Tox *m, wchar_t *line)
if (dircount == 0)
return -1;
if (dircount > 1)
if (dircount > 1) {
qsort(dirnames, dircount, NAME_MAX, qsort_strcasecmp_hlpr);
print_matches(self, m, dirnames, dircount, NAME_MAX);
}
return complete_line(self, dirnames, dircount, NAME_MAX);
}