1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 01:03:02 +01:00

Partially fix autocomplete behaviour for input with spaces

This commit is contained in:
jfreegman 2019-02-17 17:25:34 -05:00
parent f7b73af9a7
commit 05eda76643
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63

View File

@ -126,7 +126,7 @@ static int complete_line_helper(ToxWindow *self, const void *list, size_t n_item
snprintf(tmp, sizeof(tmp), "%s", ubuf); snprintf(tmp, sizeof(tmp), "%s", ubuf);
tmp[ctx->pos] = '\0'; tmp[ctx->pos] = '\0';
const char *s = strrchr(tmp, ' '); const char *s = dir_search ? strchr(tmp, ' ') : strrchr(tmp, ' ');
char *sub = calloc(1, strlen(ubuf) + 1); char *sub = calloc(1, strlen(ubuf) + 1);
if (sub == NULL) { if (sub == NULL) {
@ -221,9 +221,19 @@ static int complete_line_helper(ToxWindow *self, const void *list, size_t n_item
if (dir_search && *endchrs == '/') { if (dir_search && *endchrs == '/') {
const char *path_start = strchr(ubuf+1, '/'); const char *path_start = strchr(ubuf+1, '/');
if (!path_start) { // should never happen if (!path_start) {
path_start = strchr(ubuf+1, ' ');
if (!path_start) {
return -1; return -1;
} }
}
if (strlen(path_start) < 2) {
return -1;
}
++path_start;
if (file_type(path_start) == FILE_TYPE_REGULAR) { if (file_type(path_start) == FILE_TYPE_REGULAR) {
endchrs = ""; endchrs = "";