Skip to content

Highlight unusual Unicode whitespace - #926

Open
barkure (barkure) wants to merge 1 commit into
microsoft:mainfrom
barkure:highlight-unusual-whitespace
Open

Highlight unusual Unicode whitespace#926
barkure (barkure) wants to merge 1 commit into
microsoft:mainfrom
barkure:highlight-unusual-whitespace

Conversation

@barkure

Copy link
Copy Markdown
Contributor

Summary

  • add an opt-in View > Highlight Unusual Whitespace toggle with an Alt+I shortcut
  • visualize the 18 non-ASCII, non-control Unicode White_Space characters using width-preserving stand-ins and a yellow background
  • keep the setting document-specific and disabled by default, without changing buffer contents or layout
  • preserve selection visibility over highlighted whitespace and add English, Simplified Chinese, and Traditional Chinese labels

Motivation

Characters such as no-break spaces, narrow no-break spaces, ideographic spaces, and Unicode line/paragraph separators are otherwise difficult to distinguish from ordinary spacing. This follows up on the invisible-character work discussed in #188 while keeping the additional visualization explicitly opt-in.

Implementation notes

  • the existing control-character sanitizer remains the default API and behavior
  • the enabled and disabled sanitizer loops are compile-time specialized, so the default hot loop has no per-character unusual-whitespace mode check
  • replacements preserve terminal cell width, including the two-cell U+3000 IDEOGRAPHIC SPACE
  • no dependencies were added
  • in an arm64 macOS release comparison, the executable remained 518,816 bytes and the __text section increased by about 1.2 KiB

Validation

  • cargo +nightly fmt --all -- --check
  • cargo +nightly test --all-features --all-targets
  • cargo +nightly test --workspace --all-targets
  • cargo +nightly clippy --workspace --all-features --all-targets -- --no-deps --deny warnings
  • cargo +nightly test --workspace --doc
  • RUSTDOCFLAGS='-D warnings' cargo +nightly doc --workspace --no-deps
  • cargo check --workspace --all-features --all-targets

Tests cover the complete target code-point set, neighboring non-target characters, exact replacement/highlight ranges, width preservation, selection precedence, and the Alt+I toggle path.

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