Skip to content

fix: Correct header highlighting for multi-byte characters#1385

Merged
deathbeam merged 1 commit into
CopilotC-Nvim:mainfrom
ctchen222:fix/partially-Highlight
Aug 29, 2025
Merged

fix: Correct header highlighting for multi-byte characters#1385
deathbeam merged 1 commit into
CopilotC-Nvim:mainfrom
ctchen222:fix/partially-Highlight

Conversation

@ctchen222

@ctchen222 ctchen222 commented Aug 29, 2025

Copy link
Copy Markdown
Contributor

The previous implementation used vim.fn.strwidth() to calculate the end column for header highlighting. This function returns the display width, which can differ from the byte length when multi-byte characters like emojis are present.

Since the end_col for extmarks expects a byte-based index, this caused the highlighting to be applied incorrectly.

This patch corrects the issue by using the byte length (#header_value) for the end_col of the highlight extmark, while still using vim.fn.strwidth() for virt_text_win_col to ensure correct visual alignment of UI elements.

Fixes #1384

@ctchen222

Copy link
Copy Markdown
Contributor Author

Fix #1384

@deathbeam deathbeam added the bug Something isn't working label Aug 29, 2025
@deathbeam deathbeam merged commit f844a68 into CopilotC-Nvim:main Aug 29, 2025
1 check passed
@deathbeam

Copy link
Copy Markdown
Collaborator

thanks!

@all-contributors add @ctchen222 for code

@allcontributors

Copy link
Copy Markdown
Contributor

@deathbeam

I've put up a pull request to add @ctchen222! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Header text partially highlighted

2 participants