summaryrefslogtreecommitdiff
path: root/gtk/gtktextiter.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-10-04 00:22:13 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-10-04 00:22:13 +0000
commit739ffc4934dae8eb1ed2e12eaa9f4772ac715f89 (patch)
treeff46498583ea76816fbf956652b8b05488ec4aa0 /gtk/gtktextiter.c
parent3c09d348d307f4dc61de16ef8163856ebc34022f (diff)
downloadgdk-pixbuf-739ffc4934dae8eb1ed2e12eaa9f4772ac715f89.tar.gz
fix test case, it previously verified incorrect behavior
2001-10-03 Havoc Pennington <hp@redhat.com> * tests/testtextbuffer.c (logical_motion_tests): fix test case, it previously verified incorrect behavior Fixes for #61565 * gtk/gtktextiter.c (gtk_text_iter_set_line): don't return lines off the end (_gtk_text_btree_get_iter_at_line_char): don't return lines off the end (_gtk_text_btree_get_iter_at_line_byte): don't return lines off the end (gtk_text_iter_forward_lines): if on the last line, move to end of it * gtk/gtktextbtree.c (_gtk_text_btree_last_could_contain_tag): don't return a line off the end
Diffstat (limited to 'gtk/gtktextiter.c')
-rw-r--r--gtk/gtktextiter.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c
index 62cbde55b..1b8fbf931 100644
--- a/gtk/gtktextiter.c
+++ b/gtk/gtktextiter.c
@@ -2569,7 +2569,7 @@ gtk_text_iter_backward_line (GtkTextIter *iter)
/* Find first segment in line */
real->any_segment = real->line->segments;
real->segment = _gtk_text_line_byte_to_segment (real->line,
- 0, &offset);
+ 0, &offset);
g_assert (offset == 0);
@@ -2618,16 +2618,21 @@ gtk_text_iter_forward_lines (GtkTextIter *iter, gint count)
{
gint old_line;
+ if (gtk_text_iter_is_end (iter))
+ return FALSE;
+
old_line = gtk_text_iter_get_line (iter);
gtk_text_iter_set_line (iter, old_line + count);
- check_invariants (iter);
-
- /* return whether it moved, and is dereferenceable. */
- return
- (gtk_text_iter_get_line (iter) != old_line) &&
- !gtk_text_iter_is_end (iter);
+ if ((gtk_text_iter_get_line (iter) - old_line) < count)
+ {
+ /* count went past the last line, so move to end of last line */
+ if (!gtk_text_iter_is_end (iter))
+ gtk_text_iter_forward_to_end (iter);
+ }
+
+ return !gtk_text_iter_is_end (iter);
}
}
@@ -3647,7 +3652,7 @@ gtk_text_iter_set_line (GtkTextIter *iter,
check_invariants (iter);
- line = _gtk_text_btree_get_line (real->tree, line_number, &real_line);
+ line = _gtk_text_btree_get_line_no_last (real->tree, line_number, &real_line);
iter_set_from_char_offset (real, line, 0);
@@ -4887,7 +4892,7 @@ _gtk_text_btree_get_iter_at_char (GtkTextBTree *tree,
g_return_if_fail (tree != NULL);
line = _gtk_text_btree_get_line_at_char (tree, char_index,
- &line_start, &real_char_index);
+ &line_start, &real_char_index);
iter_init_from_char_offset (iter, tree, line, real_char_index - line_start);
@@ -4898,9 +4903,9 @@ _gtk_text_btree_get_iter_at_char (GtkTextBTree *tree,
void
_gtk_text_btree_get_iter_at_line_char (GtkTextBTree *tree,
- GtkTextIter *iter,
- gint line_number,
- gint char_on_line)
+ GtkTextIter *iter,
+ gint line_number,
+ gint char_on_line)
{
GtkTextRealIter *real = (GtkTextRealIter*)iter;
GtkTextLine *line;
@@ -4909,7 +4914,7 @@ _gtk_text_btree_get_iter_at_line_char (GtkTextBTree *tree,
g_return_if_fail (iter != NULL);
g_return_if_fail (tree != NULL);
- line = _gtk_text_btree_get_line (tree, line_number, &real_line);
+ line = _gtk_text_btree_get_line_no_last (tree, line_number, &real_line);
iter_init_from_char_offset (iter, tree, line, char_on_line);
@@ -4932,7 +4937,7 @@ _gtk_text_btree_get_iter_at_line_byte (GtkTextBTree *tree,
g_return_if_fail (iter != NULL);
g_return_if_fail (tree != NULL);
- line = _gtk_text_btree_get_line (tree, line_number, &real_line);
+ line = _gtk_text_btree_get_line_no_last (tree, line_number, &real_line);
iter_init_from_byte_offset (iter, tree, line, byte_index);