X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=example%2Fmedit.c;h=d5cadef14a64f4dcf763e8e275aa4f345d169b9b;hb=3f080bc2168f9ecaa9654b2f73285c1d4b397ac8;hp=f63a5b69c5cda18da50ce4ff1e087b4d1f54d9f1;hpb=87cc4409589efab496ef43e325197f1c17b55120;p=m17n%2Fm17n-lib.git diff --git a/example/medit.c b/example/medit.c index f63a5b6..d5cadef 100644 --- a/example/medit.c +++ b/example/medit.c @@ -2184,7 +2184,7 @@ surrounding_text_handler (MInputContext *ic, MSymbol command) { int len = (int) mplist_value (ic->plist); int pos; - MText *surround = NULL; + MText *surround; if (len < 0) { @@ -2200,11 +2200,10 @@ surrounding_text_handler (MInputContext *ic, MSymbol command) pos = nchars; surround = mtext_duplicate (mt, cursor.from, pos); } - if (surround) - { - mplist_set (ic->plist, Mtext, surround); - m17n_object_unref (surround); - } + else + surround = mtext (); + mplist_set (ic->plist, Mtext, surround); + m17n_object_unref (surround); } else if (command == Minput_delete_surrounding_text) {