From 6893b58753b476ff79e8aed5ebe73e5e42b89c43 Mon Sep 17 00:00:00 2001 From: handa Date: Tue, 8 Nov 2005 12:48:32 +0000 Subject: [PATCH] (delete_char): Fix the case of deleting the previous multiple characters. (surrounding_text_handler): Check number characters to delete. --- example/medit.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/example/medit.c b/example/medit.c index 6465fd8..df7c7ba 100644 --- a/example/medit.c +++ b/example/medit.c @@ -950,6 +950,8 @@ delete_char (int n) from = cursor.from, to = from + n; else { + from = cursor.from + n; + to = cursor.from; if (cursor.from == cur.from) { /* We are at the beginning of line. */ @@ -963,13 +965,6 @@ delete_char (int n) reseat (info.line_from); } update_cursor (pos, 1); - from = cursor.from; - to = cursor.to; - } - else - { - from = cursor.from - 1; - to = cursor.from; } } @@ -2204,8 +2199,18 @@ surrounding_text_handler (MInputContext *ic, MSymbol command) { int len = (int) mplist_value (ic->plist); - if (len != 0) - delete_char (len); + if (len < 0) + { + if (corsor.from + len < 0) + len = - corsor.from; + delete_char (len); + } + else if (len > 0) + { + if (corsor.from + len > nchars) + len = nchars - corsor.from; + delete_char (len); + } } } -- 1.7.10.4