From 2031bbb50673def7b45ee1df5c8678a649eb27b1 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sun, 9 Jun 2013 16:39:25 +0400 Subject: [PATCH] Ticket #2245: mcedit: entire file wordcompletion failed ...if word to be comleted is begun from begin of file. Signed-off-by: Andrew Borodin --- src/editor/editcmd.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c index 57bba8a47..e469bbacf 100644 --- a/src/editor/editcmd.c +++ b/src/editor/editcmd.c @@ -1093,7 +1093,7 @@ pipe_mail (const edit_buffer_t * buf, char *to, char *subject, char *cc) static gboolean edit_find_word_start (const edit_buffer_t * buf, off_t * word_start, gsize * word_len) { - int c, last; + int c; off_t i; /* return if at begin of file */ @@ -1106,14 +1106,12 @@ edit_find_word_start (const edit_buffer_t * buf, off_t * word_start, gsize * wor return FALSE; /* search start of word to be completed */ - for (i = 2;; i++) + for (i = 1;; i++) { - /* return if at begin of file */ - if (buf->curs1 < i) - return FALSE; + int last; last = c; - c = edit_buffer_get_byte (buf, buf->curs1 - i); + c = edit_buffer_get_byte (buf, buf->curs1 - i - 1); if (is_break_char (c)) { @@ -1121,12 +1119,13 @@ edit_find_word_start (const edit_buffer_t * buf, off_t * word_start, gsize * wor if (isdigit (last)) return FALSE; - *word_start = buf->curs1 - (i - 1); /* start found */ - *word_len = (gsize) (i - 1); break; } } + /* success */ + *word_start = buf->curs1 - i; /* start found */ + *word_len = (gsize) i; return TRUE; }