Ticket #2957: 0001-mcedit-fix-autocompletion-2.patch

File 0001-mcedit-fix-autocompletion-2.patch, 1.7 KB (added by andrew_b, 9 years ago)

Optimized patch

  • src/editor/editcmd_dialogs.c

    From 154f6a427557e6ae93a386f303e4c9888caa45a2 Mon Sep 17 00:00:00 2001
    From: Andrew Borodin <aborodin@vmail.ru>
    Date: Thu, 31 Jan 2013 14:10:50 +0400
    Subject: [PATCH] mcedit: fix autocompletion.
    
    Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
    ---
     src/editor/editcmd_dialogs.c | 21 ++++++---------------
     1 file changed, 6 insertions(+), 15 deletions(-)
    
    diff --git a/src/editor/editcmd_dialogs.c b/src/editor/editcmd_dialogs.c
    index aa9f145..ae15957 100644
    a b editcmd_dialog_completion_show (WEdit * edit, int max_len, int word_len, 
    386386    if (run_dlg (compl_dlg) == B_ENTER) 
    387387    { 
    388388        listbox_get_current (compl_list, &curr, NULL); 
    389         if (curr) 
     389        if (curr != NULL) 
    390390        { 
    391391#ifdef HAVE_CHARSET 
    392             GString *temp, *temp2; 
    393             temp = g_string_new (""); 
    394             for (curr += word_len; *curr; curr++) 
    395                 g_string_append_c (temp, *curr); 
     392            GString *temp; 
    396393 
    397             temp2 = str_convert_to_input (temp->str); 
     394            temp = str_convert_to_input (curr); 
    398395 
    399             if (temp2 && temp2->len) 
    400             { 
    401                 g_string_free (temp, TRUE); 
    402                 temp = temp2; 
    403             } 
    404             else 
    405                 g_string_free (temp2, TRUE); 
    406             for (curr = temp->str; *curr; curr++) 
     396            for (curr = temp->str + word_len; *curr != '\0'; curr++) 
    407397                edit_insert (edit, *curr); 
     398 
    408399            g_string_free (temp, TRUE); 
    409400#else 
    410             for (curr += word_len; *curr; curr++) 
     401            for (curr += word_len; *curr != '\0'; curr++) 
    411402                edit_insert (edit, *curr); 
    412403#endif 
    413404        }