[#21851] Bugfix: [#21254] text editor jump to line crash
authorCampbell Barton <ideasman42@gmail.com>
Wed, 31 Mar 2010 08:33:43 +0000 (08:33 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 31 Mar 2010 08:33:43 +0000 (08:33 +0000)
 by Ignacio Fern├índez (hellmoon666)

source/blender/editors/space_text/text_ops.c

index ce7db83d6d82e3c7c293238f3fb78c958f900428..8cb2b4be62838cd4f344b2ef5e9c04043fa9eafc 100644 (file)
@@ -1595,10 +1595,12 @@ static int jump_exec(bContext *C, wmOperator *op)
        int line= RNA_int_get(op->ptr, "line");
        short nlines= txt_get_span(text->lines.first, text->lines.last)+1;
 
-       if(line < 1 || line > nlines)
-               return OPERATOR_CANCELLED;
-
-       txt_move_toline(text, line-1, 0);
+       if(line < 1)
+               txt_move_toline(text, 1, 0);
+       else if(line > nlines)
+               txt_move_toline(text, nlines-1, 0);
+       else
+               txt_move_toline(text, line-1, 0);
 
        text_update_cursor_moved(C);
        WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text);
@@ -1606,6 +1608,12 @@ static int jump_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
+static int jump_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       return WM_operator_props_dialog_popup(C,op,200,100);
+
+}
+
 void TEXT_OT_jump(wmOperatorType *ot)
 {
        /* identifiers */
@@ -1614,7 +1622,7 @@ void TEXT_OT_jump(wmOperatorType *ot)
        ot->description= "Jump cursor to line";
        
        /* api callbacks */
-       ot->invoke=  WM_operator_props_popup;
+       ot->invoke= jump_invoke;
        ot->exec= jump_exec;
        ot->poll= text_edit_poll;