[gtksourceview/gtksourcecompletion] Fixed getting current word in providers
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtksourceview/gtksourcecompletion] Fixed getting current word in providers
- Date: Sat, 19 Sep 2009 13:05:08 +0000 (UTC)
commit cd63785df30d7fec53b157aaad7d586974c1770f
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Sat Sep 19 15:00:55 2009 +0200
Fixed getting current word in providers
tests/gsc-provider-devhelp.c | 16 ++++++++++++----
tests/gsc-provider-test.c | 16 ++++++++++++----
2 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/tests/gsc-provider-devhelp.c b/tests/gsc-provider-devhelp.c
index 41ef3d7..c0f6242 100644
--- a/tests/gsc-provider-devhelp.c
+++ b/tests/gsc-provider-devhelp.c
@@ -151,16 +151,24 @@ get_word_at_iter (GtkTextIter *iter)
{
GtkTextIter start = *iter;
gint line = gtk_text_iter_get_line (iter);
+ gboolean went_back = TRUE;
if (!gtk_text_iter_backward_char (&start))
{
return NULL;
}
+
+ while (went_back &&
+ line == gtk_text_iter_get_line (&start) &&
+ is_word_char (gtk_text_iter_get_char (&start)))
+ {
+ went_back = gtk_text_iter_backward_char (&start);
+ }
- while (line == gtk_text_iter_get_line (&start) &&
- is_word_char (gtk_text_iter_get_char (&start)) &&
- gtk_text_iter_backward_char (&start))
- ;
+ if (went_back)
+ {
+ gtk_text_iter_forward_char (&start);
+ }
if (gtk_text_iter_equal (iter, &start))
{
diff --git a/tests/gsc-provider-test.c b/tests/gsc-provider-test.c
index e72e1e1..281515d 100644
--- a/tests/gsc-provider-test.c
+++ b/tests/gsc-provider-test.c
@@ -97,6 +97,7 @@ get_word_at_iter (GtkTextIter *iter)
{
GtkTextIter start = *iter;
gint line = gtk_text_iter_get_line (iter);
+ gboolean went_back = TRUE;
if (!gtk_text_iter_ends_word (iter))
{
@@ -108,10 +109,17 @@ get_word_at_iter (GtkTextIter *iter)
return NULL;
}
- while (line == gtk_text_iter_get_line (&start) &&
- is_word_char (gtk_text_iter_get_char (&start)) &&
- gtk_text_iter_backward_char (&start))
- ;
+ while (went_back &&
+ line == gtk_text_iter_get_line (&start) &&
+ is_word_char (gtk_text_iter_get_char (&start)))
+ {
+ went_back = gtk_text_iter_backward_char (&start);
+ }
+
+ if (went_back)
+ {
+ gtk_text_iter_forward_char (&start);
+ }
if (gtk_text_iter_equal (iter, &start))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]