Index: vteaccess.c
===================================================================
RCS file: /cvs/gnome/vte/src/vteaccess.c,v
retrieving revision 1.44
diff -u -p -r1.44 vteaccess.c
--- vteaccess.c	1 May 2004 07:12:51 -0000	1.44
+++ vteaccess.c	26 Oct 2004 10:40:53 -0000
@@ -1005,7 +1027,6 @@ vte_terminal_accessible_get_text_somewhe
 					  priv->snapshot_attributes->len);
 			break;
 		case ATK_TEXT_BOUNDARY_WORD_START:
-		case ATK_TEXT_BOUNDARY_WORD_END:
 			/* Back up to the previous non-word-word transition. */
 			while (offset > 0) {
 				prev = vte_terminal_accessible_get_character_at_offset(text, offset - 1);
@@ -1074,6 +1095,88 @@ vte_terminal_accessible_get_text_somewhe
 			}
 			*end_offset = offset;
 			break;
+		case ATK_TEXT_BOUNDARY_WORD_END:
+			/* Back up to the previous word-non-word transition. */
+			current = vte_terminal_accessible_get_character_at_offset(text, offset);
+			while (offset > 0) {
+				prev = vte_terminal_accessible_get_character_at_offset(text, offset - 1);
+				if (vte_terminal_is_word_char(terminal, prev) &&
+				    !vte_terminal_is_word_char(terminal, current)) {
+					break;
+				} else {
+					offset--;
+					current = prev;
+				}
+			}
+			*start_offset = offset;
+			/* If we're looking for the word end before this one, 
+			 * keep searching by backing up to the previous word 
+			 * character and then searching for the word-end 
+			 * before that. */
+			if (direction == direction_previous) {
+				while (offset > 0) {
+					prev = vte_terminal_accessible_get_character_at_offset(text, offset - 1);
+					if (vte_terminal_is_word_char(terminal, prev)) {
+						offset--;
+					} else {
+						break;
+					}
+				}
+				current = vte_terminal_accessible_get_character_at_offset(text, offset);
+				while (offset > 0) {
+					prev = vte_terminal_accessible_get_character_at_offset(text, offset - 1);
+					if (vte_terminal_is_word_char(terminal, prev) &&
+					    !vte_terminal_is_word_char(terminal, current)) {
+						break;
+					} else {
+						offset--;
+						current = prev;
+					}
+				}
+				*start_offset = offset;
+			}
+			/* If we're looking for the word end after this one,
+			 * search forward by scanning forward for the next
+			 * word character, then the next non-word character
+			 * after that. */
+			if (direction == direction_next) {
+				while (offset < priv->snapshot_characters->len) {
+					current = vte_terminal_accessible_get_character_at_offset(text, offset);
+					if (!vte_terminal_is_word_char(terminal, current)) {
+						offset++;
+					} else {
+						break;
+					}
+				}
+				while (offset < priv->snapshot_characters->len) {
+					current = vte_terminal_accessible_get_character_at_offset(text, offset);
+					if (vte_terminal_is_word_char(terminal, current)) {
+						offset++;
+					} else {
+						break;
+					}
+				}
+				*start_offset = offset;
+			}
+			/* Now find the next word end. */
+			while (offset < priv->snapshot_characters->len) {
+				current = vte_terminal_accessible_get_character_at_offset(text, offset);
+				if (!vte_terminal_is_word_char(terminal, current)) {
+					offset++;
+				} else {
+					break;
+				}
+			}
+			while (offset < priv->snapshot_characters->len) {
+				current = vte_terminal_accessible_get_character_at_offset(text, offset);
+				if (vte_terminal_is_word_char(terminal, current)) {
+					offset++;
+				} else {
+					break;
+				}
+			}
+			*end_offset = offset;
+			break;
 		case ATK_TEXT_BOUNDARY_LINE_START:
 		case ATK_TEXT_BOUNDARY_LINE_END:
 			/* Figure out which line we're on.  If the start of the
