From 7f184ee2bad9e02f3c3329d7b8b2d9f0125fbe75 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 6 Nov 2020 10:36:08 +0100 Subject: [PATCH] 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 Bug existed since version 2.8.1, commit 2439e1e4. --- src/text.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/text.c b/src/text.c index 79bc026d..00570835 100644 --- a/src/text.c +++ b/src/text.c @@ -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