Ticket #1486: mc-4.7.0-pre1.completion.patch

File mc-4.7.0-pre1.completion.patch, 2.3 KB (added by angel_il, 12 years ago)
  • edit/editcmd.c

    diff -Naur mc-4.7.0-pre1~/edit/editcmd.c mc-4.7.0-pre1/edit/editcmd.c
    old new  
    22712271    GString *temp; 
    22722272    mc_search_t *srch; 
    22732273 
     2274    long last_byte = start; 
     2275 
    22742276    srch = mc_search_new(match_expr, -1); 
    22752277    if (srch == NULL) 
    22762278        return 0; 
     
    22802282    srch->search_fn = edit_search_cmd_callback; 
    22812283 
    22822284    /* collect max MAX_WORD_COMPLETIONS completions */ 
    2283     start--; 
     2285    start = -1; 
    22842286    while (*num < MAX_WORD_COMPLETIONS) { 
    22852287        /* get next match */ 
    2286         if (mc_search_run (srch, (void *) edit, start+1, edit->last_byte, &len) == FALSE) 
     2288        if (mc_search_run (srch, (void *) edit, start+1, last_byte, &len) == FALSE) 
    22872289            break; 
    22882290        start = srch->normal_offset; 
    22892291 
     
    23052307                        (char *) &temp->str[word_len], 
    23062308                        max (len, compl[i].len) - word_len 
    23072309                    ) == 0) { 
     2310                struct selection this = compl[i]; 
     2311                for (++i; i < *num; i++) { 
     2312                    compl[i - 1] = compl[i]; 
     2313                } 
     2314                compl[*num - 1] = this; 
    23082315                skip = 1; 
    23092316                break;          /* skip it, already added */ 
    23102317            } 
     
    23482355    bufpos = &edit->buffers1[word_start >> S_EDIT_BUF_SIZE] 
    23492356        [word_start & M_EDIT_BUF_SIZE]; 
    23502357 
    2351     match_expr = g_strdup_printf ("(^|\\s)%.*s[^\\s\\.=\\+\\{\\}\\[\\]\\(\\)\\\\\\!\\,<>\\?\\/@#\\$%%\\^&\\*\\~\\|\\\"'\\:\\;]+", word_len, bufpos); 
     2358    match_expr = g_strdup_printf ("\\b%.*s[a-zA-Z_0-9]+", word_len, bufpos); 
    23522359 
    23532360    /* collect the possible completions              */ 
    23542361    /* start search from begin to end of file */ 
    23552362    max_len = 
    2356         edit_collect_completions (edit, 0, word_len, match_expr, 
     2363        edit_collect_completions (edit, word_start, word_len, match_expr, 
    23572364                                  (struct selection *) &compl, &num_compl); 
    23582365 
    23592366    if (num_compl > 0) { 
  • edit/editcmd_dialogs.c

    diff -Naur mc-4.7.0-pre1~/edit/editcmd_dialogs.c mc-4.7.0-pre1/edit/editcmd_dialogs.c
    old new  
    296296    add_widget (compl_dlg, compl_list); 
    297297 
    298298    /* fill the listbox with the completions */ 
    299     for (i = 0; i < num_compl; i++) 
     299    for (i = num_compl - 1; i >= 0; i--) /* reverse order */ 
    300300        listbox_add_item (compl_list, LISTBOX_APPEND_AT_END, 0, (char *) compl[i].text, NULL); 
    301301 
    302302    /* pop up the dialog */