Skip to content

refactor(core_editor): extract grapheme boundary helpers into free functions#1068

Merged
fdncred merged 1 commit intonushell:mainfrom
kronberger-droid:grapheme-helpers
May 9, 2026
Merged

refactor(core_editor): extract grapheme boundary helpers into free functions#1068
fdncred merged 1 commit intonushell:mainfrom
kronberger-droid:grapheme-helpers

Conversation

@kronberger-droid
Copy link
Copy Markdown
Contributor

Extracts grapheme-boundary computation out of LineBuffer into a sibling graphemes module as free functions over &str.
The two affected LineBuffer methods become one-line wrappers and behavior is unchanged.

The existing methods only ever touched self.lines, so promoting them to free functions gives one source of truth for grapheme math reedline-wide.

Side benefit: deduplicates the next_back().map(...).unwrap_or(0) pattern in word_right_end_index and big_word_right_end_index.

Also unblocks helix-mode operations (#1061 and follow-ups) that need to operate on &str rather than &LineBuffer.

14 unit tests cover ASCII, multi-byte UTF-8, CJK, combining marks, ZWJ emoji sequences, and round-trip invariants. Full suite (835) unchanged.

…nctions

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kronberger-droid kronberger-droid changed the title refactor(core_editor)L extract grapheme boundary helpers into free functions refactor(core_editor): extract grapheme boundary helpers into free functions May 8, 2026
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 9, 2026

nice cleanup! Thanks!

@fdncred fdncred merged commit fc3a274 into nushell:main May 9, 2026
7 checks passed
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.

2 participants