fix(bug): process unicode character properly#107
Merged
YousefHadder merged 1 commit intoYousefHadder:mainfrom Nov 4, 2025
Merged
fix(bug): process unicode character properly#107YousefHadder merged 1 commit intoYousefHadder:mainfrom
YousefHadder merged 1 commit intoYousefHadder:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR improves multi-byte character support in the backspace handler for non-list lines. The change replaces simple byte-based string slicing with character-aware operations using vim.fn.charidx() and vim.fn.byteidx(), and switches from manual string manipulation to nvim_buf_set_text() API.
- Converts byte-based backspace deletion to character-aware deletion for multi-byte characters (e.g., emojis, non-ASCII)
- Adds guard against attempting to delete before the start of the line
- Uses Neovim's native buffer text API for more robust text manipulation
Comments suppressed due to low confidence (1)
lua/markdown-plus/list/handlers.lua:315
- The backspace handling within list content (lines 310-315) still uses byte-based string slicing, which will fail to properly delete multi-byte characters. This is inconsistent with the fix applied to non-list backspace (lines 282-289). The same character-aware logic using
vim.fn.charidx()andvim.fn.byteidx()should be applied here.
-- Default backspace in list content
if col > 0 then
local new_line = current_line:sub(1, col - 1) .. current_line:sub(col + 1)
utils.set_line(row, new_line)
utils.set_cursor(row, col - 1)
end
YousefHadder
approved these changes
Nov 4, 2025
Owner
YousefHadder
left a comment
There was a problem hiding this comment.
LGTM, Thank you for contributing the fix.
3 tasks
Owner
|
@all-contributors please add @SuniRein for code |
Contributor
|
I've put up a pull request to add @SuniRein! 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Make
<BS>delete multi-byte unicode character properly.Type of Change
Related Issues
Fixes #106
Testing
Checklist