linting: avoid putting the cursor beyond the end of the line

Some linters report a column position (assuming a TAB to be 8 spaces)
instead of a byte index, so make sure that the cursor is not placed
out of bounds when interpreting such a column number as an index.

This fixes https://savannah.gnu.org/bugs/?59419.
Reported-by: Ava McWhorter <qwerty0s.e.m@gmail.com>

Bug existed since version 2.8.1, commit 2439e1e4.
master
Benno Schulenberg 2020-11-06 10:36:08 +01:00
parent ec9fc5d320
commit 7f184ee2ba
1 changed files with 3 additions and 0 deletions

View File

@ -2823,7 +2823,10 @@ void do_linter(void)
}
if (tmplint != curlint) {
/* Put the cursor at the reported position, but don't go beyond EOL
* when the second number is a column number instead of an index. */
goto_line_posx(curlint->lineno, curlint->colno - 1);
openfile->current_x = actual_x(openfile->current->data, openfile->placewewant);
titlebar(NULL);
adjust_viewport(CENTERING);
#ifdef ENABLE_LINENUMBERS