forked from AuroraMiddleware/gtk
textiter: fix bug in FindLogAttrFunc functions
attrs[len] is the last PangoLogAttr available, at the iter position after the last character of the line. For a line in the middle or the start of the buffer, the '\n' is taken into account by 'len'. For example the is_word_end is generally reached before the '\n', not after. But for the last line in the buffer, where there is no trailing '\n', it is important to test until attrs[len]. The bug didn't occur before because find_by_log_attrs() worked directly on the iter passed as the function argument. But now it is no longer the case. https://bugzilla.gnome.org/show_bug.cgi?id=618852
This commit is contained in:
parent
76f3866bd3
commit
69d20f53e2
@ -2895,7 +2895,7 @@ find_word_end_func (const PangoLogAttr *attrs,
|
||||
++offset;
|
||||
|
||||
/* Find end of next word */
|
||||
while (offset < len)
|
||||
while (offset <= len)
|
||||
{
|
||||
if (attrs[offset].is_word_end)
|
||||
{
|
||||
@ -2982,7 +2982,7 @@ find_sentence_end_func (const PangoLogAttr *attrs,
|
||||
++offset;
|
||||
|
||||
/* Find end of next sentence */
|
||||
while (offset < len)
|
||||
while (offset <= len)
|
||||
{
|
||||
if (attrs[offset].is_sentence_end)
|
||||
{
|
||||
@ -3580,7 +3580,7 @@ find_forward_cursor_pos_func (const PangoLogAttr *attrs,
|
||||
if (!already_moved_initially)
|
||||
++offset;
|
||||
|
||||
while (offset < len)
|
||||
while (offset <= len)
|
||||
{
|
||||
if (attrs[offset].is_cursor_position)
|
||||
{
|
||||
|
@ -396,7 +396,7 @@ test_word_boundaries (void)
|
||||
check_forward_word_end ("ab ", 1, 2, TRUE);
|
||||
check_forward_word_end ("ab ", 2, 2, FALSE);
|
||||
check_forward_word_end ("ab ", 3, 3, FALSE);
|
||||
check_forward_word_end ("ab", 0, 0, FALSE); /* FIXME result_offset should be 2 */
|
||||
check_forward_word_end ("ab", 0, 2, FALSE);
|
||||
|
||||
check_backward_word_start (" ab", 3, 1, TRUE);
|
||||
check_backward_word_start (" ab", 2, 1, TRUE);
|
||||
@ -520,7 +520,7 @@ test_cursor_positions (void)
|
||||
check_cursor_position ("a\r\nb", TRUE, 0, 1, TRUE);
|
||||
check_cursor_position ("a\r\nb", TRUE, 1, 3, TRUE);
|
||||
check_cursor_position ("a\r\nb", TRUE, 2, 3, TRUE);
|
||||
check_cursor_position ("a\r\nb", TRUE, 3, 3, FALSE); /* FIXME result_offset should be 4 */
|
||||
check_cursor_position ("a\r\nb", TRUE, 3, 4, FALSE);
|
||||
check_cursor_position ("a\r\nb", TRUE, 4, 4, FALSE);
|
||||
|
||||
/* backward */
|
||||
@ -662,7 +662,7 @@ test_sentence_boundaries (void)
|
||||
check_forward_sentence_end ("Hi. ", 2, 3, TRUE);
|
||||
check_forward_sentence_end ("Hi. ", 3, 3, FALSE);
|
||||
check_forward_sentence_end ("Hi. ", 4, 4, FALSE);
|
||||
check_forward_sentence_end ("Hi.", 0, 0, FALSE); /* FIXME result_offset should be 3 */
|
||||
check_forward_sentence_end ("Hi.", 0, 3, FALSE);
|
||||
|
||||
check_backward_sentence_start (" Hi.", 4, 1, TRUE);
|
||||
check_backward_sentence_start (" Hi.", 3, 1, TRUE);
|
||||
|
Loading…
Reference in New Issue
Block a user