comparison src/charset.c @ 26843:1e3c49c09260 v8.2.3950

patch 8.2.3950: going beyond the end of the line with /%V Commit: https://github.com/vim/vim/commit/94f3192b03ed27474db80b4d3a409e107140738b Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 30 15:29:18 2021 +0000 patch 8.2.3950: going beyond the end of the line with /\%V Problem: Going beyond the end of the line with /\%V. Solution: Check for valid column in getvcol().
author Bram Moolenaar <Bram@vim.org>
date Thu, 30 Dec 2021 16:30:04 +0100
parents 9f7568104726
children 268f6a3511df
comparison
equal deleted inserted replaced
26842:df509756e36d 26843:1e3c49c09260
1238 line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE); 1238 line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
1239 if (pos->col == MAXCOL) 1239 if (pos->col == MAXCOL)
1240 posptr = NULL; // continue until the NUL 1240 posptr = NULL; // continue until the NUL
1241 else 1241 else
1242 { 1242 {
1243 // Special check for an empty line, which can happen on exit, when 1243 colnr_T i;
1244 // ml_get_buf() always returns an empty string. 1244
1245 if (*ptr == NUL) 1245 // In a few cases the position can be beyond the end of the line.
1246 pos->col = 0; 1246 for (i = 0; i < pos->col; ++i)
1247 if (ptr[i] == NUL)
1248 {
1249 pos->col = i;
1250 break;
1251 }
1247 posptr = ptr + pos->col; 1252 posptr = ptr + pos->col;
1248 if (has_mbyte) 1253 if (has_mbyte)
1249 // always start on the first byte 1254 // always start on the first byte
1250 posptr -= (*mb_head_off)(line, posptr); 1255 posptr -= (*mb_head_off)(line, posptr);
1251 } 1256 }