bug in cursor up navigation fixed
[claws.git] / src / gtkstext.c
index 95592d8a965839a6b3f04e833625d7ec62922427..a24f202b3226dda25d3a84e9ec4c16ec7e9b0c1d 100644 (file)
@@ -4260,27 +4260,27 @@ static void move_cursor_to_display_row_up(GtkSText *text)
        bdrf              data = { 0 };
        int                       new_index;
        int                   col;
-       GtkSPropertyMark  mark = find_this_line_start_mark(text, text->cursor_mark.index, &text->cursor_mark);
+       GtkSPropertyMark  mark;
+
+       mark = find_this_line_start_mark(text, text->cursor_mark.index, &text->cursor_mark);
 
        /* top of buffer */
        if (mark.index == 0) {
-               XDEBUG ( ("%s(%d) top of buffer", __FILE__, __LINE__) );        
-               return;
+               XDEBUG ( ("%s(%d) top of buffer", __FILE__, __LINE__) );
        }
 
-       /* we need to previous DISPLAY row not the previous BUFFER line, so we go one line back,
-        * and iterate over the lines until we have a LineParams that matches the original */
-
+       /* we need previous DISPLAY row not the previous BUFFER line, so we go to start
+        * of paragraph, and iterate over the lines until we have a LineParams that matches 
+        * the original */
        lp  = CACHE_DATA(text->current_line);
        col = (text->cursor_mark.index - lp.start.index);
        data.start = lp.start.index;
        data.end   = lp.end.index;
 
        /* get the previous line */
-       if (mark.index - 1 > 0) {
+       if (mark.index != 0) {
                decrement_mark(&mark);
-               XDEBUG( ("%s(%d) mark decrement", __FILE__, __LINE__) );
-               if (mark.index - 1 > 0) {
+               if (mark.index != 0) {
                        GtkSPropertyMark smark = mark;
                        XDEBUG( ("%s(%d) finding line start mark", __FILE__, __LINE__) );
                        mark = find_this_line_start_mark(text, smark.index -1,  &smark);
@@ -4319,11 +4319,15 @@ static gint forward_display_row_fetcher(GtkSText *text,
                                                                                fdrf       *data)
 {
        if (data->found) {
+               XDEBUG( ("%s(%d) - FW RETURNS. search (%d, %d),  current (%d, %d)",
+                               __FILE__, __LINE__, data->start, data->end, lp->start.index, lp->end.index) );
                data->lp = *lp;
                data->completed = TRUE;
                return TRUE;
        }
        else if (range_intersect(data->start, data->end, lp->start.index, lp->end.index)) {
+               XDEBUG( ("%s(%d) - FW FOUND IT. search (%d, %d),  current (%d, %d)",
+                               __FILE__, __LINE__, data->start, data->end, lp->start.index, lp->end.index) );
                data->found = TRUE;
                return FALSE;
        }
@@ -4337,18 +4341,21 @@ static void move_cursor_to_display_row_down     (GtkSText *text)
        LineParams              lp;
        int                             new_index;
        int                             col;
-       GtkSPropertyMark  mark = find_this_line_start_mark(text, text->cursor_mark.index, &text->cursor_mark);
+       GtkSPropertyMark  mark;
        fdrf                    data = { FALSE, FALSE };
 
+       mark = find_this_line_start_mark(text, text->cursor_mark.index, &text->cursor_mark);
        lp  = CACHE_DATA(text->current_line);
        col = (text->cursor_mark.index - lp.start.index);
 
        data.start = lp.start.index;
        data.end   = lp.end.index;
 
-       /* find the next DISPLAY line */ 
+       /* find the next DISPLAY line */
+       XDEBUG( ("%s(%d) - FW iterating", __FILE__, __LINE__) ) ;
        line_params_iterate(text, &mark, NULL, FALSE, &data, 
                                                (LineIteratorFunction)forward_display_row_fetcher);     
+       XDEBUG( ("%s(%d) - FW done iterating", __FILE__, __LINE__) );                                           
        
        if (data.completed) {
                if (col < text->persist_column) col = text->persist_column; 
@@ -4358,6 +4365,7 @@ static void move_cursor_to_display_row_down       (GtkSText *text)
                        new_index = data.lp.end.index;
                }
                /* and move the cursor */
+               XDEBUG( ("%s(%d) - FW set pos %d", __FILE__, __LINE__, new_index) );
                gtk_stext_set_position_X(GTK_EDITABLE(text), new_index);                
        }
 }