Skip to content

Conversation

@jserv
Copy link
Contributor

@jserv jserv commented Jan 11, 2026

Summary by cubic

Refactored textfield input handling into small helper functions to improve readability and keep UTF-8 correctness. Added tests for selection boundary behavior and arrow/word navigation.

  • Refactors

    • Broke iui_process_text_input_selection into helpers: textfield_clamp_state, textfield_insert_char, textfield_move_left/right, textfield_handle_cursor_movement.
    • Centralized cursor movement logic and clamping to valid UTF-8 boundaries.
  • Bug Fixes

    • Left/Right with an active selection now collapse the selection to its boundary without moving again (matches expected behavior).

Written for commit bfc4440. Summary will update on new commits.

jserv added 2 commits January 11, 2026 23:53
Test suite in tests/test-input.c verifies:
- Selection shrinking behavior (cursor jumps to boundary before move)
- Word skipping with Ctrl+Shift
- UTF-8 boundary handling
- Selection extension with Shift held
This breaks down the large iui_process_text_input_selection function in
src/input.c into modular static helper functions to improve readability
and maintainability.

The following helpers were introduced:
- textfield_clamp_state: Validate cursor/selection boundaries
- textfield_insert_char: Handle UTF-8 insertion logic
- textfield_move_left/right: Word skipping and cursor movement
- textfield_handle_cursor_movement: Unified key event dispatch
@jserv jserv changed the title Refine textfield Extract Textfield helpers Jan 11, 2026
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@jserv jserv merged commit 65b4926 into main Jan 11, 2026
12 checks passed
@jserv jserv deleted the refine-textfield branch January 11, 2026 17:18
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