[FL-2017] Gui: correct empty folder handling in file_select. #824

This commit is contained in:
あく 2021-11-16 17:10:06 +03:00 committed by GitHub
parent 4cb986b534
commit 65e6ab5b8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -142,9 +142,11 @@ static bool file_select_input_callback(InputEvent* event, void* context) {
} }
} else if(event->key == InputKeyOk) { } else if(event->key == InputKeyOk) {
if(file_select->callback != NULL) { if(file_select->callback != NULL) {
size_t files = 0;
if(file_select->buffer) { if(file_select->buffer) {
with_view_model( with_view_model(
file_select->view, (FileSelectModel * model) { file_select->view, (FileSelectModel * model) {
files = model->file_count;
strlcpy( strlcpy(
file_select->buffer, file_select->buffer,
string_get_cstr(model->filename[model->position]), string_get_cstr(model->filename[model->position]),
@ -153,8 +155,9 @@ static bool file_select_input_callback(InputEvent* event, void* context) {
return false; return false;
}); });
}; };
if(files > 0) {
file_select->callback(true, file_select->context); file_select->callback(true, file_select->context);
}
} }
consumed = true; consumed = true;
} }