Skip to content

util: Recognize Unicode whitespace in byte slices - #4281

Open
Don-Yin wants to merge 1 commit into
micro-editor:masterfrom
Don-Yin:fix-unicode-whitespace
Open

Don-Yin wants to merge 1 commit into
micro-editor:masterfrom
Don-Yin:fix-unicode-whitespace

Conversation

@Don-Yin

@Don-Yin Don-Yin commented Oct 23, 2026

Copy link
Copy Markdown

I reproduced this with a buffer containing text : appending a non-breaking space (U+00A0) marked the existing trailing whitespace as newly typed, unlike appending a normal space. IsBytesWhitespace([]byte("\u00a0")) returned false because it checked each UTF-8 byte separately.

I replaced the loop with bytes.TrimSpace so it agrees with the Unicode whitespace checks used elsewhere. I added regressions for the helper and the buffer insertion path.

I ran make test, go test ./..., and rebuilt micro.

UTF-8 whitespace classification before and after

Signed-off-by: Don Yin <Don_Yin@outlook.com>
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