Skip to content

feat: lift Cut/Copy/Paste from ted into Editor as first-class commands#107

Merged
tig merged 3 commits into
developfrom
copilot/lift-cut-copy-paste-into-editor
May 13, 2026
Merged

feat: lift Cut/Copy/Paste from ted into Editor as first-class commands#107
tig merged 3 commits into
developfrom
copilot/lift-cut-copy-paste-into-editor

Conversation

Copilot AI commented May 13, 2026

Copy link
Copy Markdown
Contributor

Moves clipboard operations from ted's private helpers into Editor proper so any consumer gets Cut/Copy/Paste for free via Command.Cut/Copy/Paste.

Editor commands (Editor.Commands.cs)

  • Register Command.Cut, Command.Copy, Command.Paste with Ctrl+X/C/V in DefaultKeyBindings
  • Copy: no-op when no selection; otherwise writes SelectedText to App.Clipboard
  • Cut: no-op when ReadOnly, no selection, or clipboard write fails; copies then removes inside RunUpdate() → single undo step. Aborts without deleting text if TrySetClipboardData returns false (prevents destructive behavior when clipboard is unavailable).
  • Paste: no-op when ReadOnly; inserts/replaces inside RunUpdate() → single undo step; multi-line content preserved verbatim

ted cleanup (TedApp.EditCommands.cs)

  • Removed private Cut(), Copy(), Paste() wrappers
  • Menu items now bind via Command alone (no Action delegate needed)

Decision log (specs/decisions.md)

  • DEC-005: No-selection Cut/Copy = no-op (matches VS Code default; avoids implicit "current line" semantic)

Tests (EditorClipboardTests.cs)

  • Round-trip copy→paste, paste-replaces-selection, multi-line paste (LF + CRLF)
  • Cut produces single undo step
  • ReadOnly blocks Cut/Paste but allows Copy
  • No-selection is no-op for both Cut and Copy
  • Cut is no-op when clipboard is unavailable (proves non-destructive guard)
  • All clipboard tests use FakeClipboard for cross-platform CI compatibility (macOS/Windows headless)

- Add Command.Cut, Command.Copy, Command.Paste handlers in Editor.Commands.cs
- Register Ctrl+X/C/V key bindings via DefaultKeyBindings dictionary
- Cut and Paste use Document.RunUpdate() for single undo step
- No-selection = no-op for Cut/Copy (matching VS Code default)
- ReadOnly blocks Cut/Paste; Copy still allowed
- Remove redundant Cut/Copy/Paste methods from TedApp.EditCommands.cs
- Log DEC-005 decision in specs/decisions.md
- Add EditorClipboardTests with round-trip, multi-line, undo, and ReadOnly tests

Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/2f4d5823-f52a-4b6e-9125-c65584a6131f

Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Cut, Copy, and Paste commands to Editor feat: lift Cut/Copy/Paste from ted into Editor as first-class commands May 13, 2026
Copilot finished work on behalf of tig May 13, 2026 14:35
Copilot AI requested a review from tig May 13, 2026 14:35
@tig

tig commented May 13, 2026

Copy link
Copy Markdown
Member

@copilot see TG PR #5277 and ensure this work is compatible. It should be, but I just want to make sure.

@tig
tig marked this pull request as ready for review May 13, 2026 14:49

Copilot AI commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot see TG PR #5277 and ensure this work is compatible. It should be, but I just want to make sure.

Verified — fully compatible. TG PR #5277 introduces a parallel paste pathway (View.OnPasted virtual for ANSI bracketed paste payloads) that doesn't touch Command.Paste or the Command enum at all. Our implementation reads from App.Clipboard via Command.Paste, which is the existing keybinding-driven path and remains unaffected.

When #5277 eventually merges, the Editor could optionally override OnPasted() to handle bracketed paste directly (terminal-delivered payload, no clipboard read), but that's additive and not required for compatibility with the current design.

Copilot finished work on behalf of tig May 13, 2026 14:52

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb0c8956f7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Terminal.Gui.Editor/Editor.Commands.cs Outdated
@tig

tig commented May 13, 2026

Copy link
Copy Markdown
Member

@copilot see CR feedback. Ensure there's a test that proves the CR feedback (or not) and then fix. CI?CD is failing and that must be fixed too.

- Cut is now a no-op if TrySetClipboardData returns false (prevents
  destructive text loss when clipboard is unavailable)
- All clipboard tests use FakeClipboard to work on macOS/Windows CI
  where system clipboard is unavailable in headless mode
- New test: Cut_NoOp_When_Clipboard_Unavailable proves the guard

Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/500faa4d-d1bf-477f-b2a5-2e599bb69c9e

Co-authored-by: tig <585482+tig@users.noreply.github.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copilot AI commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot see CR feedback. Ensure there's a test that proves the CR feedback (or not) and then fix. CI?CD is failing and that must be fixed too.

Fixed in 24e52c4:

  1. CR feedback addressed: Cut now aborts (no-op) if TrySetClipboardData returns false — text is never destroyed without a successful clipboard write.
  2. CI fixed: All clipboard tests now inject a FakeClipboard so they pass on macOS/Windows CI where the system clipboard isn't available headless.
  3. New test added: Cut_NoOp_When_Clipboard_Unavailable uses a FakeClipboard(false, isSupportedAlwaysFalse: true) to prove the guard works.

Copilot finished work on behalf of tig May 13, 2026 15:09
@tig
tig merged commit 7355f22 into develop May 13, 2026
8 checks passed
@tig
tig deleted the copilot/lift-cut-copy-paste-into-editor branch May 13, 2026 16:29
tig added a commit that referenced this pull request May 17, 2026
…rvey

All four beta features (find-and-replace #104, clipboard #107, word-wrap
#106, multi-caret #105) plus vertical-multi-caret #133 and syntax-theme
Phase 2 #134 have merged since the 2026-05-13 plan snapshot. Bring the
spec set back in line with develop:

- Per-feature status lines -> Done with PR/issue refs (clipboard,
  multi-caret, find-and-replace, word-wrap, vertical-multi-caret,
  syntax-theme).
- plan.md rescoped to the beta endgame: new "Done (beta)" table, a
  "Remaining for beta" that reflects no feature work is left (only
  external/verification/cut items), evidence-checked DoD boxes,
  refreshed dependency graph and header.
- decisions.md: OPEN-005 annotated as settled by syntax-theme; add
  OPEN-006 (single-line/input-mode decision).
- codex-autonomous-sprint.md: flag stale work pool.
- New specs/textview-parity-gap/spec.md: survey of TextView
  capabilities Editor lacks (autocomplete, overwrite mode,
  single-line mode, kill-ring, context menu) with dispositions;
  wired into plan.md follow-ups.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

clipboard: lift Cut/Copy/Paste from ted into the Editor (Command.Cut/Copy/Paste + key bindings)

2 participants