Ticket #3648: mc-3648-04-handle-user-abort-on-backwards-view-search.patch

File mc-3648-04-handle-user-abort-on-backwards-view-search.patch, 1.7 KB (added by and, 9 years ago)
  • src/viewer/search.c

    From a36b410b4368745011f683421d24cc22d13fd624 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Sat, 21 May 2016 14:31:38 +0000
    Subject: [PATCH] Handle user abort on backwards view search
    
    Currently backwards view search loops mc_search_run() until match or search end,
    but not on user abort request.
    
    Respect newly introduced MC_SEARCH_E_ABORT error status
    and exit backwards search loop on user request.
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/viewer/search.c | 14 +++++++++-----
     1 file changed, 9 insertions(+), 5 deletions(-)
    
    diff --git a/src/viewer/search.c b/src/viewer/search.c
    index 34ecfba..e0cf17b 100644
    a b mcview_find (mcview_search_status_msg_t * ssm, off_t search_start, off_t search_ 
    136136                && mc_search_is_fixed_search_str (view->search)) 
    137137                search_end = search_start + view->search->original_len; 
    138138 
    139             if (mc_search_run (view->search, (void *) ssm, search_start, search_end, len) 
    140                 && view->search->normal_offset == search_start) 
     139            if (mc_search_run (view->search, (void *) ssm, search_start, search_end, len)) 
    141140            { 
    142                 if (view->text_nroff_mode) 
    143                     view->search->normal_offset++; 
    144                 return TRUE; 
     141                if (view->search->normal_offset == search_start) 
     142                { 
     143                    if (view->text_nroff_mode) 
     144                        view->search->normal_offset++; 
     145                    return TRUE; 
     146                } 
    145147            } 
     148            else if (view->search->error == MC_SEARCH_E_ABORT) 
     149                return FALSE; 
    146150 
    147151            search_start--; 
    148152        }