From a47ac4affa33ec43b9073f5c154879185d5e9fb7 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sun, 7 Mar 2021 12:48:42 -0500 Subject: change focus to search term, even when find is already open --- find.c | 6 +++--- ted.c | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/find.c b/find.c index 2878015..b682a2b 100644 --- a/find.c +++ b/find.c @@ -451,14 +451,14 @@ static void find_menu_frame(Ted *ted, Rect menu_bounds) { } static void find_open(Ted *ted, bool replace) { - if (!ted->find && ted->active_buffer) { + if (ted->active_buffer && ted_is_regular_buffer(ted, ted->active_buffer)) { ted->prev_active_buffer = ted->active_buffer; ted_switch_to_buffer(ted, &ted->find_buffer); ted->find = true; buffer_select_all(ted->active_buffer); + ted->replace = replace; + find_update(ted, true); } - ted->replace = replace; - find_update(ted, true); } static void find_close(Ted *ted) { diff --git a/ted.c b/ted.c index 8f999a6..9e4fe1b 100644 --- a/ted.c +++ b/ted.c @@ -51,6 +51,10 @@ static void ted_full_path(Ted *ted, char const *relpath, char *abspath, size_t a path_full(ted->cwd, relpath, abspath, abspath_size); } +static bool ted_is_regular_buffer(Ted *ted, TextBuffer *buffer) { + return buffer >= ted->buffers && buffer < ted->buffers + TED_MAX_BUFFERS; +} + // Check the various places a file could be, and return the full path. static Status ted_get_file(Ted const *ted, char const *name, char *out, size_t outsz) { if (ted->search_cwd && fs_file_exists(name)) { -- cgit v1.2.3