diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-02-22 14:32:29 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-02-22 14:32:29 +0300 |
commit | d60a5cfc552e0f5b6e9143a1d85fcc0208021e1a (patch) | |
tree | d8be151f4961f7ba65a2da228bed60d07203fe44 /source/blender/python/intern/bpy_interface.c | |
parent | ef6cbc3da0af5a05f59969025d75ae6567c0b299 (diff) |
feature back from 2.4x where a python error moves the cursor to the error line, added moving to exact column for syntax errors too.
Diffstat (limited to 'source/blender/python/intern/bpy_interface.c')
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index b6f0182a267..9ed1865d70d 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -35,6 +35,7 @@ #include "bpy.h" #include "bpy_rna.h" #include "bpy_util.h" +#include "bpy_traceback.h" #include "DNA_space_types.h" #include "DNA_text_types.h" @@ -327,6 +328,18 @@ void BPY_python_end(void) } +static void python_script_error_jump_text(struct Text *text) +{ + int lineno; + int offset; + python_script_error_jump(text->id.name+2, &lineno, &offset); + if(lineno != -1) { + /* select the line with the error */ + txt_move_to(text, lineno - 1, INT_MAX, FALSE); + txt_move_to(text, lineno - 1, offset, TRUE); + } +} + /* super annoying, undo _PyModule_Clear(), bug [#23871] */ #define PYMODULE_CLEAR_WORKAROUND @@ -369,6 +382,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st MEM_freeN( buf ); if(PyErr_Occurred()) { + python_script_error_jump_text(text); BPY_text_free_code(text); } } @@ -414,6 +428,9 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st } if (!py_result) { + if(text) { + python_script_error_jump_text(text); + } BPy_errors_to_report(reports); } else { Py_DECREF( py_result ); |