summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorailin-nemui <ailin-nemui@users.noreply.github.com>2017-09-05 10:17:22 +0200
committerGitHub <noreply@github.com>2017-09-05 10:17:22 +0200
commitbe70fa5eb750ed337a55463c68d5a51b47d1efcd (patch)
tree30845e69690dc699463ef7a5b2a3c4f5730ef25c
parent13471013f31be1e2f459dfce9bc7425800b2824b (diff)
parent7086eae650a616615bc81e688cdfa44d444463e0 (diff)
downloadirssi-be70fa5eb750ed337a55463c68d5a51b47d1efcd.zip
Merge pull request #741 from LemonBoy/complete
Complete filenames ending with a slash
-rw-r--r--src/fe-common/core/completion.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c
index 78b1b24b..e78fe7d5 100644
--- a/src/fe-common/core/completion.c
+++ b/src/fe-common/core/completion.c
@@ -321,6 +321,10 @@ GList *filename_complete(const char *path, const char *default_path)
g_return_val_if_fail(path != NULL, NULL);
+ if (path[0] == '\0') {
+ return NULL;
+ }
+
list = NULL;
/* get directory part of the path - expand ~/ */
@@ -350,7 +354,14 @@ GList *filename_complete(const char *path, const char *default_path)
g_free_and_null(dir);
}
- basename = g_path_get_basename(path);
+ len = strlen(path);
+ /* g_path_get_basename() returns the component before the last slash if
+ * the path ends with a directory separator, that's not what we want */
+ if (len > 0 && path[len - 1] == G_DIR_SEPARATOR) {
+ basename = g_strdup("");
+ } else {
+ basename = g_path_get_basename(path);
+ }
len = strlen(basename);
/* add all files in directory to completion list */