summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-03-06 13:57:12 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-03-06 13:57:12 -0500
commit88946161165f62b955c3c25b7d6760b77fac42c6 (patch)
tree3c62433d532fc59d617fe7b1eb1358a11e16f3a8
parent87fe34bdbaa2d840d5d4e988ffd789eb3e7a039a (diff)
fix "save as" menu
-rw-r--r--ui.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/ui.c b/ui.c
index 62015ee..a01b99f 100644
--- a/ui.c
+++ b/ui.c
@@ -374,25 +374,23 @@ static char *file_selector_update(Ted *ted, FileSelector *fs) {
strbuf_printf(path, "%s%s%s", cwd, cwd[strlen(cwd)-1] == PATH_SEPARATOR ? "" : PATH_SEPARATOR_STR, option_chosen);
char *ret = NULL;
- if (fs->create_menu) {
- // don't need to check anything
+ switch (fs_path_type(path)) {
+ case FS_NON_EXISTENT:
+ case FS_OTHER:
+ if (fs->create_menu)
+ ret = str_dup(path); // you can only select non-existent things if this is a create menu
+ break;
+ case FS_FILE:
+ // selected a file!
ret = str_dup(path);
- } else {
- switch (fs_path_type(path)) {
- case FS_NON_EXISTENT: break;
- case FS_OTHER: break;
-
- case FS_FILE:
- // selected a file!
- ret = str_dup(path);
- break;
- case FS_DIRECTORY:
- // cd there
- file_selector_cd(ted, fs, option_chosen);
- buffer_clear(line_buffer);
- break;
- }
+ break;
+ case FS_DIRECTORY:
+ // cd there
+ file_selector_cd(ted, fs, option_chosen);
+ buffer_clear(line_buffer);
+ break;
}
+
free(option_chosen);
if (ret) {
return ret;