[gspell] current word: check current word if insertion not at cursor position
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell] current word: check current word if insertion not at cursor position
- Date: Thu, 3 Mar 2016 15:44:09 +0000 (UTC)
commit 3da59d4ad7efc373a10117f5d1297ee801ba16f4
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Feb 29 18:52:56 2016 +0100
current word: check current word if insertion not at cursor position
gspell/gspell-inline-checker-text-buffer.c | 18 ++++++++++++++++--
testsuite/test-inline-checker-text-buffer.c | 14 +++++++++++++-
2 files changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/gspell/gspell-inline-checker-text-buffer.c b/gspell/gspell-inline-checker-text-buffer.c
index 5bae989..8210e02 100644
--- a/gspell/gspell-inline-checker-text-buffer.c
+++ b/gspell/gspell-inline-checker-text-buffer.c
@@ -494,7 +494,6 @@ insert_text_after_cb (GtkTextBuffer *buffer,
gtk_text_iter_backward_chars (&start, g_utf8_strlen (text, length));
/* Include neighbor words */
-
if (gtk_text_iter_ends_word (&start) ||
(gtk_text_iter_inside_word (&start) &&
!gtk_text_iter_starts_word (&start)))
@@ -507,7 +506,22 @@ insert_text_after_cb (GtkTextBuffer *buffer,
gtk_text_iter_forward_word_end (&end);
}
- spell->check_current_word = FALSE;
+ /* Check current word? */
+ if (gtk_text_buffer_get_has_selection (buffer))
+ {
+ spell->check_current_word = TRUE;
+ }
+ else
+ {
+ GtkTextIter cursor_pos;
+
+ gtk_text_buffer_get_iter_at_mark (buffer,
+ &cursor_pos,
+ gtk_text_buffer_get_insert (buffer));
+
+ spell->check_current_word = !gtk_text_iter_equal (location, &cursor_pos);
+ }
+
add_subregion_to_scan (spell, &start, &end);
install_timeout (spell, TIMEOUT_DURATION_BUFFER_MODIFIED);
}
diff --git a/testsuite/test-inline-checker-text-buffer.c b/testsuite/test-inline-checker-text-buffer.c
index f46dbec..417bb31 100644
--- a/testsuite/test-inline-checker-text-buffer.c
+++ b/testsuite/test-inline-checker-text-buffer.c
@@ -344,7 +344,9 @@ test_current_word (void)
6, 10,
-1);
- /* Delete the 'e' programmatically, not at the cursor position. */
+ /* Delete the 'e' programmatically, not at the cursor position.
+ * Hello -> Hllo
+ */
gtk_text_buffer_get_iter_at_offset (buffer, &start, 1);
gtk_text_buffer_get_iter_at_offset (buffer, &end, 2);
gtk_text_buffer_delete (buffer, &start, &end);
@@ -354,6 +356,16 @@ test_current_word (void)
5, 9, /* "nrst" still highlighted */
-1);
+ /* Insert 'e' programmatically, not at the cursor position.
+ * Hllo -> Hello
+ */
+ gtk_text_buffer_get_iter_at_offset (buffer, &iter, 1);
+ gtk_text_buffer_insert (buffer, &iter, "e", -1);
+ check_highlighted_words (buffer,
+ inline_checker,
+ 6, 10, /* "nrst" still highlighted */
+ -1);
+
g_object_unref (inline_checker);
g_object_unref (buffer);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]