Skip to content

fix(ui): wrap prompt words without misplacing the cursor - #401

Merged
qorzj merged 1 commit into
lessweb:mainfrom
mvanhorn:fix/327-prompt-word-wrapping
Nov 6, 2026
Merged

qorzj merged 1 commit into
lessweb:mainfrom
mvanhorn:fix/327-prompt-word-wrapping

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Motivation

Words were split across lines in the prompt input and submitted prompt echoes even when they could fit on the next line. Cursor positioning also needed to follow words moved by wrapping.

Both displays used hard wrapping. Cursor measurement counted only characters before the cursor, so it could not account for the rest of a word moving that cursor onto another row.

Summary

The input and prompt echoes now use word wrapping. Cursor measurement wraps the complete line with wrap-ansi and maps source offsets through grapheme normalization and tab expansion. Inline cursor rendering highlights whole graphemes and avoids duplicate cursor cells at segment boundaries. Regression tests cover wrapping, cursor movement, resizing, and submission of the original buffer.

Tests

  • Ran npm test locally on macOS for the deepcode-cli PromptEchoLine change; it passed.
  • js_tests found no targeted test runner or touched test files.
  • npm test passed all 88 tests.
  • npm run check was invoked, but the supplied transcript shows no result.
  • The tests in packages/cli/src/tests/message-view.test.ts, packages/cli/src/tests/prompt-input-keys.test.ts and packages/cli/src/tests/prompt-input-wrap.test.ts fail without the fix in the deepcode-cli PromptEchoLine change (checked by reverting the source changes).
  • The changed spec packages/cli/src/tests/message-view.test.ts did not run here: no test runner for it was available.
  • The changed spec packages/cli/src/tests/prompt-input-keys.test.ts did not run here: no test runner for it was available.
  • The new spec packages/cli/src/tests/prompt-input-wrap.test.ts did not run here: no test runner for it was available.

Fixes #327

The input and prompt echoes now use word wrapping. Cursor measurement
wraps the complete line with wrap-ansi and maps source offsets through
grapheme normalization and tab expansion. Inline cursor rendering
highlights whole graphemes and avoids duplicate cursor cells at segment
boundaries. Regression tests cover wrapping, cursor movement, resizing,
and submission of the original buffer.

Fixes lessweb#327
@qorzj
qorzj merged commit 13d7e79 into lessweb:main Nov 6, 2026
6 checks passed
@mvanhorn

mvanhorn commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Appreciate the merge, @qorzj. Prompt words should now wrap onto the next line without the cursor landing in the wrong spot.

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] 输入框英文单词在行尾被硬截断,应整词换行

2 participants