From 48c29aef29355254b89ccf883c08201f51dc23a0 Mon Sep 17 00:00:00 2001 From: its your bedtime <23366927+itsyourbedtime@users.noreply.github.com> Date: Mon, 30 Aug 2021 14:33:12 +0300 Subject: [PATCH] [FL-1539] Archive app: correct cursor index after key renaming #675 --- applications/archive/archive.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/applications/archive/archive.c b/applications/archive/archive.c index f30eeda68..c9667e665 100644 --- a/applications/archive/archive.c +++ b/applications/archive/archive.c @@ -416,6 +416,7 @@ static void archive_text_input_callback(void* context) { string_get_cstr(archive->browser.path), archive->browser.text_input_buffer); + string_set(archive->browser.name, archive->browser.text_input_buffer); // append extension ArchiveFile_t* file; @@ -437,11 +438,25 @@ static void archive_text_input_callback(void* context) { } view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewMain); + archive_get_filenames(archive); + + with_view_model( + archive->view_archive_main, (ArchiveViewModel * model) { + model->idx = 0; + while(model->idx < files_array_size(model->files)) { + ArchiveFile_t* current = files_array_get(model->files, model->idx); + if(!string_search(current->name, archive->browser.text_input_buffer)) { + break; + } + ++model->idx; + } + return true; + }); + + update_offset(archive); string_clear(buffer_src); string_clear(buffer_dst); - - archive_get_filenames(archive); } static void archive_enter_text_input(ArchiveApp* archive) {