@@ -149,8 +149,11 @@ M.extract_highlights_co = function(bufnr)
149149 return text .codepoints_pos (str , tabwidth )
150150 end , lines )
151151
152- --- @type fun ( row : integer , char_idx : integer ): integer
152+ --- @type fun ( row : integer , char_idx : integer ): integer ?
153153 local char_idx_to_codepoint_idx = function (row , char_idx )
154+ if code_point_list [row ] == nil then
155+ return nil
156+ end
154157 local utf8_idx = text .byte_index_to_utf8_index (char_idx , utf8_pos_list [row ])
155158 local code_point_idx = code_point_list [row ][utf8_idx ]
156159 return code_point_idx
@@ -179,10 +182,10 @@ M.extract_highlights_co = function(bufnr)
179182 if not hide then
180183 local from = row == h .start_row and h .start_col or 1
181184 local to = row == h .end_row and h .end_col or string.len (lines [row ])
182- from = char_idx_to_codepoint_idx (row , from )
183- to = char_idx_to_codepoint_idx (row , to )
184- if from ~= nil and to ~= nil then
185- for col = from , to do
185+ local from_codepint = char_idx_to_codepoint_idx (row , from )
186+ local to_codepint = char_idx_to_codepoint_idx (row , to )
187+ if from_codepint ~= nil and to_codepint ~= nil then
188+ for col = from_codepint , to_codepint do
186189 local mrow , mcol = coord .codepoint_to_mcodepoint (vrow , col )
187190 if mcol > minimap_width then
188191 break
0 commit comments