Skip to content

Merge develop into main for v0.1.18 release#12

Merged
ShortArrow merged 2 commits into
mainfrom
develop
May 31, 2026
Merged

Merge develop into main for v0.1.18 release#12
ShortArrow merged 2 commits into
mainfrom
develop

Conversation

@ShortArrow

Copy link
Copy Markdown
Owner

Summary

Release 0.1.18 ships the Issue #6 multi-byte cursor fix.

Tests

Test plan

Closes #6.

…loses #6)

Shells send --cursor in their own native unit: bash/zsh/clink/nu count
Unicode scalar values (= chars); pwsh counts UTF-16 code units. The
Rust hook used the raw value as a byte offset, which agreed by
accident on ASCII but split mid-character on Japanese, emoji, or any
non-ASCII input.

Reporter's PoC reproduced on real WSL bash: typing
`ls ./おはよう ./test1`, moving cursor between `う` and the space,
pressing Space repeatedly grew a misplaced gap between `は` and `よ`
instead of accumulating after `う`. The same misalignment silently
corrupted any expansion that ran against a multi-byte buffer in any
shell.

Fix:
- cmd::hook converts the incoming cursor to a byte offset once at the
  cmd/app boundary via app::hook::shell_cursor_to_byte
  (char_cursor_to_byte for bash/zsh/clink/nu, utf16_cursor_to_byte
  for pwsh).
- app::hook::render wraps the domain renderer and converts back on
  the way out (byte_cursor_to_char or byte_cursor_to_utf16). zsh is
  excluded because its renderer splits LBUFFER/RBUFFER by byte and
  the cursor number never reaches zsh.
- pwsh's UTF-16 path handles surrogate pairs (emoji = 1 char / 4
  bytes / 2 UTF-16 code units), rounding mid-surrogate down to the
  previous boundary.

Bake-mode bash dispatcher (0.1.17, Git Bash) is unaffected — pure-
bash slicing is char-based.

Tidy First (same PR): cmd::hook's three short-circuit paths
(oversize line, paste pending, config load failure) shared a five-
line "insert space at cursor" shape. Collapsed onto
app::hook::insert_space_action.

Tests:
- 28 new unit tests in app::hook (four conversion helpers × ASCII /
  Japanese (3-byte BMP) / emoji (4-byte / 2 UTF-16 units) /
  combining / RTL / NUL / empty / past-end clamping / round-trip
  property against inverses).
- 7 new e2e tests in tests/cli_integration.rs::hook_* driving
  `runex hook --shell <s>` for each shell with a multi-byte buffer.
- Manual verify on WSL bash with 0.1.18: reporter's PoC no longer
  reproduces.

Bump version 0.1.17 → 0.1.18 + CHANGELOG.

Closes #6.
@ShortArrow
ShortArrow merged commit ae0d812 into main May 31, 2026
6 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.

BUG: Insertion of whitespace characters in strange positions when Entering multibyte characters args

1 participant