From 8d8ff02bbf0e91a2781430ae8914b2f314a8029a Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Sat, 27 Dec 2008 09:46:21 +0000 Subject: [PATCH] Fix behaviour for search-toggle-regex text_typeahead_handler: Document that passing -2 for action_id will cause a search without error reporting. This behaviour is unintentionally the current behaviour of text_typeahead_handler, but now it is documented so that it can be used. input_line_event_handler: When rewinding, pass -2 for the action_id parameter to the handler instead of passing again whatever action led to the rewinding. The old behavior of input_line_event_handler was particularly problematic with the search-toggle-regex action and the text_typeahead_handler handler: input_line_event_handler would call the handler with ACT_EDIT_SEARCH_TOGGLE_REGEX, and the handler would toggle the setting and perform the search again; then if the search string no longer matched anything, the handler would return INPUT_LINE_REWIND to input_line_event_handler, which would rewind and call the handler with ACT_EDIT_SEARCH_TOGGLE_REGEX again, thus toggling the option back to the original setting. With the new behaviour, input_line_event_handler will not repeat the same action when re-invoking the handler; in the above example with search-toggle-regex, the search string will simply be rewound until it matches with the new setting. --- src/bfu/inpfield.c | 3 +++ src/viewer/text/search.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/bfu/inpfield.c b/src/bfu/inpfield.c index 8a8c8fc8..70b6042c 100644 --- a/src/bfu/inpfield.c +++ b/src/bfu/inpfield.c @@ -856,6 +856,9 @@ cancel_input_line: update_dialog_data(dlg_data); + /* Set action_id to -2 to signal to the handler that it should + * not report errors or take any action except to search. */ + action_id = -2; goto send_action_to_handler; case INPUT_LINE_PROCEED: diff --git a/src/viewer/text/search.c b/src/viewer/text/search.c index 2d45dca6..7ae2f34f 100644 --- a/src/viewer/text/search.c +++ b/src/viewer/text/search.c @@ -1378,6 +1378,9 @@ do_typeahead(struct session *ses, struct document_view *doc_view, /** @name Typeahead * @{ */ +/** @a action_id can be a value from enum edit_action, in which case the + * approriate action is performed; -1, which indicates to search and report any + * errors; or -2, which indicates to search without reporting any errors. */ static enum input_line_code text_typeahead_handler(struct input_line *line, int action_id) {