From 508301a2ef7c85a0efc6c8241e09493d5f34052a Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 4 Oct 2021 11:31:22 +0200 Subject: [PATCH] browser: make the keystrokes ^W^Y and ^W^V work again The functions to_first_file() and to_last_file() can get called from do_statusbar_input(), which is called indirectly from do_prompt(), and are expected to make the corresponding adjustment. This fixes https://savannah.gnu.org/bugs/?61273. Bug existed since version 5.0, commit 07c1ac90. --- src/browser.c | 15 ++++++++++++++- src/global.c | 6 ------ src/prototypes.h | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/browser.c b/src/browser.c index a369f476..e07d5bf2 100644 --- a/src/browser.c +++ b/src/browser.c @@ -359,7 +359,8 @@ void search_filename(bool forwards) #endif } - findfile(last_search, forwards); + if (response == 0 || response == -2) + findfile(last_search, forwards); } /* Search again without prompting for the last given search string, @@ -380,6 +381,18 @@ void research_filename(bool forwards) } } +/* Select the first file in the list -- called by ^W^Y. */ +void to_first_file(void) +{ + selected = 0; +} + +/* Select the last file in the list -- called by ^W^V. */ +void to_last_file(void) +{ + selected = list_length - 1; +} + /* Strip one element from the end of path, and return the stripped path. * The returned string is dynamically allocated, and should be freed. */ char *strip_last_component(const char *path) diff --git a/src/global.c b/src/global.c index 0e9b0618..a15f32c1 100644 --- a/src/global.c +++ b/src/global.c @@ -301,12 +301,6 @@ void flip_goto(void) void to_files(void) { } -void to_first_file(void) -{ -} -void to_last_file(void) -{ -} void goto_dir(void) { } diff --git a/src/prototypes.h b/src/prototypes.h index 3fe5cd8a..807c5a9b 100644 --- a/src/prototypes.h +++ b/src/prototypes.h @@ -191,6 +191,8 @@ typedef void (*functionptrtype)(void); #ifdef ENABLE_BROWSER void browser_refresh(void); char *browse_in(const char *inpath); +void to_first_file(void); +void to_last_file(void); #endif /* Most functions in chars.c. */ @@ -636,8 +638,6 @@ void flip_replace(void); void flip_goto(void); #ifdef ENABLE_BROWSER void to_files(void); -void to_first_file(void); -void to_last_file(void); void goto_dir(void); #endif #ifndef NANO_TINY