Skip to content

fix(buffer): wrap non-virtualtext nvim_buf_set_extmark in pcall#214

Open
fei6409 wants to merge 1 commit into
catgoose:masterfrom
fei6409:master
Open

fix(buffer): wrap non-virtualtext nvim_buf_set_extmark in pcall#214
fei6409 wants to merge 1 commit into
catgoose:masterfrom
fei6409:master

Conversation

@fei6409
Copy link
Copy Markdown

@fei6409 fei6409 commented May 5, 2026

When scrolling or editing rapidly, asynchronous updates or byte-offset calculation misalignments (e.g. in files with control characters like '^[[1;31m' or multi-byte sequences) can attempt to apply highlights to invalid column ranges. This causes Neovim to throw an "Invalid 'end_col': out of range" error in function nvim_buf_set_extmark().

Wrap the non-virtualtext highlight application in a pcall to safely ignore stale or invalid column offsets. This provides the same protection already present in the virtualtext highlighting logic in the same function.

When scrolling or editing rapidly, asynchronous updates or byte-offset
calculation misalignments (e.g. in files with control characters like
'^[[1;31m' or multi-byte sequences) can attempt to apply highlights to
invalid column ranges. This causes Neovim to throw an
"Invalid 'end_col': out of range" error in function nvim_buf_set_extmark().

Wrap the non-virtualtext highlight application in a pcall to safely ignore
stale or invalid column offsets. This provides the same protection already
present in the virtualtext highlighting logic in the same function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant