From 7ecabdad0b2af14c440e5d773aee52a8bda6a825 Mon Sep 17 00:00:00 2001 From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com> Date: Thu, 6 Jul 2006 00:12:59 -0500 Subject: [PATCH] Treat '_' as a word character too --- moo/mooedit/mootextsearch.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/moo/mooedit/mootextsearch.c b/moo/mooedit/mootextsearch.c index 8888fec5..c7c5845e 100644 --- a/moo/mooedit/mootextsearch.c +++ b/moo/mooedit/mootextsearch.c @@ -243,6 +243,14 @@ get_regex (const char *pattern, } +inline static gboolean +is_word_char (const GtkTextIter *iter) +{ + gunichar c = gtk_text_iter_get_char (iter); + return c == '_' || g_unichar_isalnum (c); +} + + static gboolean is_whole_word (const GtkTextIter *start, const GtkTextIter *end) @@ -254,19 +262,13 @@ is_whole_word (const GtkTextIter *start, if (!gtk_text_iter_starts_line (&s)) { - gunichar c; gtk_text_iter_backward_char (&s); - c = gtk_text_iter_get_char (&s); - if (g_unichar_isalnum (c)) + if (is_word_char (&s)) return FALSE; } - if (!gtk_text_iter_ends_line (&e)) - { - gunichar c = gtk_text_iter_get_char (&e); - if (g_unichar_isalnum (c)) - return FALSE; - } + if (!gtk_text_iter_ends_line (&e) && is_word_char (&e)) + return FALSE; return TRUE; }