Python: select the start-end range of syntax errors

Python 3.10's syntax errors can specify a range.
Use this for text editor error selection.
This commit is contained in:
Campbell Barton
2022-03-28 17:04:19 +11:00
parent 0ce6ed4753
commit 1466f480c4
3 changed files with 74 additions and 13 deletions

View File

@@ -37,12 +37,14 @@
static void python_script_error_jump_text(Text *text, const char *filepath)
{
int lineno;
int offset;
python_script_error_jump(filepath, &lineno, &offset);
int lineno, lineno_end;
int offset, offset_end;
python_script_error_jump(filepath, &lineno, &offset, &lineno_end, &offset_end);
if (lineno != -1) {
/* select the line with the error */
txt_move_to(text, lineno - 1, INT_MAX, false);
/* Start at the end so cursor motion that looses the selection,
* leaves the cursor from the most useful place.
* Also, the end can't always be set, so don't give it priority. */
txt_move_to(text, lineno_end - 1, offset_end, false);
txt_move_to(text, lineno - 1, offset, true);
}
}