[gspell/wip/tune-current-word: 3/3] current word: improve current word handling on text deletion
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell/wip/tune-current-word: 3/3] current word: improve current word handling on text deletion
- Date: Sat, 5 Mar 2016 14:20:35 +0000 (UTC)
commit e82467a4eda12014e11594e2dd547037aca0dddd
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Mar 5 15:06:25 2016 +0100
current word: improve current word handling on text deletion
gspell/gspell-inline-checker-text-buffer.c | 43 +++++++++++++++++----------
1 files changed, 27 insertions(+), 16 deletions(-)
---
diff --git a/gspell/gspell-inline-checker-text-buffer.c b/gspell/gspell-inline-checker-text-buffer.c
index e005e96..147c32c 100644
--- a/gspell/gspell-inline-checker-text-buffer.c
+++ b/gspell/gspell-inline-checker-text-buffer.c
@@ -622,6 +622,33 @@ delete_range_before_cb (GtkTextBuffer *buffer,
end_adjusted = *end;
adjust_iters (&start_adjusted, &end_adjusted, ADJUST_MODE_INCLUDE_NEIGHBORS);
add_subregion_to_scan (spell, &start_adjusted, &end_adjusted);
+
+ /* Check current word? */
+ if (gtk_text_buffer_get_has_selection (buffer) ||
+ gtk_text_iter_get_line (start) != gtk_text_iter_get_line (end) ||
+ (gtk_text_iter_get_line_offset (end) - gtk_text_iter_get_line_offset (start)) > 1 ||
+ (!gtk_text_iter_inside_word (start) && !gtk_text_iter_ends_word (start)))
+ {
+ 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));
+
+ if (gtk_text_iter_equal (start, &cursor_pos) ||
+ gtk_text_iter_equal (end, &cursor_pos))
+ {
+ spell->check_current_word = FALSE;
+ }
+ else
+ {
+ spell->check_current_word = TRUE;
+ }
+ }
}
static void
@@ -640,22 +667,6 @@ delete_range_after_cb (GtkTextBuffer *buffer,
adjust_iters (&start_adjusted, &end_adjusted, ADJUST_MODE_INCLUDE_NEIGHBORS);
add_subregion_to_scan (spell, &start_adjusted, &end_adjusted);
- /* 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 (start, &cursor_pos);
- }
-
install_timeout (spell, TIMEOUT_DURATION_BUFFER_MODIFIED);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]