Skip to content

CAMEL-24372: camel-tui YAML editor undo/redo, block ops, word nav, find in edit - #25407

Closed
atiaomar1978-hub wants to merge 2 commits into
apache:mainfrom
atiaomar1978-hub:cursor/CAMEL-24372-tui-yaml-editor-c587
Closed

CAMEL-24372: camel-tui YAML editor undo/redo, block ops, word nav, find in edit#25407
atiaomar1978-hub wants to merge 2 commits into
apache:mainfrom
atiaomar1978-hub:cursor/CAMEL-24372-tui-yaml-editor-c587

Conversation

@atiaomar1978-hub

Copy link
Copy Markdown
Contributor

Summary

Implements CAMEL-24372: enhanced plain-text edit mode in the camel-jbang TUI source viewer for YAML (and other local files).

Editor features

Shortcut Action
Ctrl+Z / Ctrl+Y / Ctrl+Shift+Z Undo / redo
Alt+↑ / Alt+↓ Move YAML list block up/down
Ctrl+D Duplicate current block
Ctrl+Shift+K Delete current block
Ctrl+/ Toggle # comment on block
Ctrl+← / Ctrl+→ Word navigation
Ctrl+Backspace / Ctrl+Delete Delete word backward/forward
Home Smart home (content indent, then column 0)
Ctrl+F, then n/N Find in edit mode

Implementation

  • SourceEditHistory — snapshot-based undo/redo stack (max 100)
  • YamlBlockEditor — YAML list-item block detection and move/duplicate/delete/comment
  • SourceEditorNavigation — word boundaries and smart home
  • SourceViewer — key bindings, footer hints, find-while-editing via SearchHighlighter
  • SearchHighlighter — edit-mode find input/navigation, closeInputOnly(), jumpToNearestMatch on confirm

Review follow-ups addressed

  • Fixed tamboui modifier key handling (isKey(KeyCode.*) instead of isUp()/isLeft()/isDelete*() with Ctrl/Alt)
  • Find-in-edit: n/N navigation aligned with view mode; Esc clears find; paste routes to find input; jump to nearest match after confirm
  • moveBlockUp cursor lands on the moved block after swap

Tests

  • YamlBlockEditorTest — block find/move/duplicate/delete/comment
  • SourceEditHistoryTest — undo/redo stack behavior
  • SourceEditorNavigationTest — word nav and smart home
  • SourceViewerEditorOpsTest — integration via SourceViewer edit mode

AI-generated PR description on behalf of atiaomar1978-hub.

cursoragent and others added 2 commits August 8, 2026 03:23
…edit

Add SourceEditHistory, YamlBlockEditor, and SourceEditorNavigation helpers
and wire them into SourceViewer edit mode for undo/redo (Ctrl+Z/Y),
YAML block move/duplicate/delete (Alt+arrows, Ctrl+D/K), comment toggle
(Ctrl+/), word navigation/delete, smart Home, and find while editing.

Includes comprehensive unit and integration tests for the new editor ops.

Co-authored-by: Omar Atie <atiaomar1978-hub@users.noreply.github.com>
Use isKey(KeyCode.*) with modifiers for Alt/Ctrl chords (tamboui only
matches unmodified keys on isUp/isLeft/isDelete*). Align find n/N with
view mode, jump to nearest match on confirm, clear find on Esc, route
paste to find input, and fix moveBlockUp cursor placement.

Co-authored-by: Omar Atie <atiaomar1978-hub@users.noreply.github.com>
@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

Bugbot review

Reviewed `cursor/CAMEL-24372-tui-yaml-editor-c587` vs `main`.

Verified fixes

  • Blocker (fixed): Alt+↑/↓, Ctrl+←/→, Ctrl+Backspace/Delete use `isKey(KeyCode.)` with modifiers — tamboui only matches unmodified keys on `isUp()`/`isLeft()`/`isDelete()`.
  • Major (fixed): Find-in-edit uses `jumpToNearestMatch`, `n`/`N` aligned with view mode, Esc clears find before discard, paste routes to find input when active.
  • Major (fixed): `moveBlockUp` cursor lands on the moved block (`previous.startRow()`).
  • Tests: Integration coverage for Alt+↓ block move and Ctrl+←/→ word nav via `handleKeyEvent`.

Remaining suggestions (non-blocking)

  • Plain `n` still navigates find when a term is active (consistent with view mode; may conflict with typing).
  • Edit render does not highlight find matches inside the TextArea widget.
  • Undo stack is per-keystroke (100 depth); large pastes may exhaust history quickly.

AI-generated review comment on behalf of atiaomar1978-hub.

@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

Grok code review

Verdict: Approve with minor follow-ups

CAMEL-24372 scope is implemented with solid helper separation and good test coverage. Key tamboui KeyEvent pitfalls were addressed before opening this upstream PR.

Strengths

  • Clean modules: `YamlBlockEditor`, `SourceEditHistory`, `SourceEditorNavigation`
  • YAML list-item block ops (move/duplicate/delete/comment) match JIRA intent
  • AssertJ tests and package-private integration tests follow project conventions
  • Footer hints document primary edit shortcuts

Minor follow-ups (optional)

  1. Find UX: Document that `n`/`N` navigate matches while a find term is active (same as view mode).
  2. Find highlighting: Consider applying `SearchHighlighter.applyHighlights` in `renderEditMode` for visual parity.
  3. Undo coalescing: Char-level snapshots may be shallow for paste-heavy edits.
  4. Footer: Add Ctrl+Shift+K and Ctrl+Y hints for discoverability.

Test coverage summary

Class Tests
`YamlBlockEditorTest` 10
`SourceEditHistoryTest` 6
`SourceEditorNavigationTest` 7
`SourceViewerEditorOpsTest` 10

Ready for human committer review.

AI-generated review comment on behalf of atiaomar1978-hub.

@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

Closing to reopen with correctly named feature/ branch per contributor workflow.

@cursor
cursor Bot deleted the cursor/CAMEL-24372-tui-yaml-editor-c587 branch August 8, 2026 03:32
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