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

File 0001-mcedit-fix-autocompletion.patch, 1.9 KB (added by andrew_b, 11 years ago)
  • src/editor/editcmd_dialogs.c

    From a054851c8f070262d3764cc6450c0585c4f009ff 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 | 24 ++++++++++--------------
     1 file changed, 10 insertions(+), 14 deletions(-)
    
    diff --git a/src/editor/editcmd_dialogs.c b/src/editor/editcmd_dialogs.c
    index aa9f145..c3500a6 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 
    392392            GString *temp, *temp2; 
    393             temp = g_string_new (""); 
    394             for (curr += word_len; *curr; curr++) 
    395                 g_string_append_c (temp, *curr); 
    396393 
    397             temp2 = str_convert_to_input (temp->str); 
     394            temp = g_string_sized_new (8); 
     395            temp2 = str_convert_to_input (curr); 
     396            curr = temp2->str; 
    398397 
    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++) 
     398            for (curr += word_len; *curr != '\0'; curr++) 
     399                g_string_append_c (temp, *curr); 
     400            g_string_free (temp2, TRUE); 
     401 
     402            for (curr = temp->str; *curr != '\0'; curr++) 
    407403                edit_insert (edit, *curr); 
    408404            g_string_free (temp, TRUE); 
    409405#else 
    410             for (curr += word_len; *curr; curr++) 
     406            for (curr += word_len; *curr != '\0'; curr++) 
    411407                edit_insert (edit, *curr); 
    412408#endif 
    413409        }