Skip to content

Fixes #4825. Unify TextField and TextView Undo/Redo/Paste/DeleteAll key bindings#4828

Merged
tig merged 8 commits intov2_developfrom
copilot/unify-textfield-textview-keybindings
Mar 11, 2026
Merged

Fixes #4825. Unify TextField and TextView Undo/Redo/Paste/DeleteAll key bindings#4828
tig merged 8 commits intov2_developfrom
copilot/unify-textfield-textview-keybindings

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 11, 2026

TextField and TextView had incompatible key bindings for Undo/Redo/Paste/DeleteAll, causing confusion when switching between controls. This PR unifies them to follow platform conventions.

Unified Bindings

Command All Platforms Non-Windows (additional)
Paste Ctrl+V
Undo Ctrl+Z Ctrl+/
Redo Ctrl+Y Ctrl+Shift+Z
DeleteAll Ctrl+Shift+D

Changes

TextField.Commands.cs

  • Removed Ctrl+R → DeleteAll (conflicted with Redo convention)
  • Added Ctrl+/ → Undo and Ctrl+Shift+Z → Redo on non-Windows platforms

TextView.Commands.cs

  • Ctrl+Y: Paste → Redo (Windows standard)
  • Ctrl+V: PageDown (Emacs) → Paste (universal standard)
  • Removed Ctrl+R → Redo and Ctrl+G → DeleteAll
  • Added Ctrl+/ → Undo and Ctrl+Shift+Z → Redo on non-Windows platforms

Breaking Changes

  • TextView users relying on Ctrl+Y for Paste must switch to Ctrl+V
  • TextView users relying on Ctrl+R for Redo must switch to Ctrl+Y

Tests

  • Updated ~45 existing test assertions that used removed keybindings (Key.R.WithCtrl for Redo → Key.Y.WithCtrl; Key.Y.WithCtrl for Paste → Key.V.WithCtrl)
  • Added new tests verifying unified bindings in both TextFieldTests and TextViewTests

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working
Original prompt

This section details on the original issue you should resolve

<issue_title>Unify TextField and TextView Undo/Redo/Paste key bindings</issue_title>
<issue_description>## Problem

TextField and TextView currently have incompatible key bindings for Undo/Redo/Paste/DeleteAll:

Command TextField TextView
Paste Ctrl+V ✓ Ctrl+Y ✗
Redo Ctrl+Y ✓ Ctrl+R ✗
DeleteAll Ctrl+R ✗ Ctrl+G ✗

This is confusing for users who switch between the two controls.

Proposed Resolution

Unify both controls to follow platform conventions:

Command All Platforms Non-Windows (additional)
Paste Ctrl+V
Undo Ctrl+Z Ctrl+/
Redo Ctrl+Y Ctrl+Shift+Z
DeleteAll Ctrl+Shift+D

Removals

  • TextField: Remove Ctrl+R for DeleteAll (conflicts with Redo convention)
  • TextView: Change Ctrl+Y from Paste → Redo (standard Windows)
  • TextView: Remove Ctrl+R for Redo
  • TextView: Remove Ctrl+G for DeleteAll

Breaking changes

  • TextView users who use Ctrl+Y for Paste → must switch to Ctrl+V (universal standard)
  • TextView users who use Ctrl+R for Redo → must switch to Ctrl+Y (Windows) or Ctrl+Shift+Z

Scope

  • Modify TextView.Commands.cs key bindings
  • Modify TextField.Commands.cs key bindings (remove Ctrl+R for DeleteAll)
  • TextValidateField, DateEditor, TimeEditor should also be verified for consistency (they support Delete/Backspace)
  • Add tests verifying unified bindings

Related to #3023 (configurable key bindings) — this should be merged before the CM key bindings PR.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@BDisp
Copy link
Copy Markdown
Collaborator

BDisp commented Mar 11, 2026

Will there be no key binding for the DeleteAll method in Non-Windows? Will it only be accessible through the context menu or by calling the DeleteAll method directly?

Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copilot AI changed the title [WIP] Unify key bindings for TextField and TextView Fixes #issue. Unify TextField and TextView Undo/Redo/Paste/DeleteAll key bindings Mar 11, 2026
Copilot finished work on behalf of tig March 11, 2026 16:25
@tig
Copy link
Copy Markdown
Collaborator

tig commented Mar 11, 2026

Will there be no key binding for the DeleteAll method in Non-Windows? Will it only be accessible through the context menu or by calling the DeleteAll method directly?

I think you mis-read the above. The table shows that Ctrl+Shift+D will work on all platforms for DeleteAll.

@tig tig changed the title Fixes #issue. Unify TextField and TextView Undo/Redo/Paste/DeleteAll key bindings Fixes ##4825. Unify TextField and TextView Undo/Redo/Paste/DeleteAll key bindings Mar 11, 2026
@tig tig changed the title Fixes ##4825. Unify TextField and TextView Undo/Redo/Paste/DeleteAll key bindings Fixes #4825. Unify TextField and TextView Undo/Redo/Paste/DeleteAll key bindings Mar 11, 2026
@BDisp
Copy link
Copy Markdown
Collaborator

BDisp commented Mar 11, 2026

I think you mis-read the above. The table shows that Ctrl+Shift+D will work on all platforms for DeleteAll.

Sorry, I missed the "All Platforms" detail.

@tig tig marked this pull request as ready for review March 11, 2026 17:44
@tig tig self-requested a review as a code owner March 11, 2026 17:44
@tig tig requested review from BDisp and Copilot March 11, 2026 17:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates Terminal.Gui’s text editing widgets to use more standard, consistent keyboard shortcuts for Undo/Redo/Paste/DeleteAll across platforms, and aligns test coverage with the new bindings.

Changes:

  • Remaps TextView commands: Ctrl+V → Paste, Ctrl+Y → Redo; removes Ctrl+V → PageDown and Ctrl+G → DeleteAll.
  • Updates TextField commands: removes Ctrl+R → DeleteAll; adds non-Windows Ctrl+/ → Undo and Ctrl+Shift+Z → Redo.
  • Updates/extends unit tests to reflect the new key bindings (including new “UnifiedKeyBindings” tests).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
Tests/UnitTestsParallelizable/Views/TextViewTests.cs Updates redo key expectations and adds new keybinding verification tests.
Tests/UnitTestsParallelizable/Views/TextView.InputTests.cs Updates redo key usage in input-focused tests.
Tests/UnitTestsParallelizable/Views/TextView.ClipboardTests.cs Updates paste key usage in clipboard tests.
Tests/UnitTestsParallelizable/Views/TextFieldTests.cs Adds new keybinding verification tests for TextField.
Tests/UnitTests/Views/TextViewTests.History.cs Updates paste/redo key usage in history tests.
Tests/UnitTests/Views/TextViewTests.cs Updates undo/redo and paste expectations to new bindings.
Terminal.Gui/Views/TextInput/TextView/TextView.Commands.cs Implements new TextView keybinding map (including non-Windows Undo/Redo alternates).
Terminal.Gui/Views/TextInput/TextField/TextField.Commands.cs Removes legacy DeleteAll binding and adds non-Windows Undo/Redo alternates.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread Tests/UnitTestsParallelizable/Views/TextView.ClipboardTests.cs Outdated
Comment thread Tests/UnitTestsParallelizable/Views/TextView.ClipboardTests.cs Outdated
Comment thread Tests/UnitTestsParallelizable/Views/TextView.InputTests.cs
Comment thread Tests/UnitTestsParallelizable/Views/TextViewTests.cs Outdated
Comment thread Tests/UnitTestsParallelizable/Views/TextViewTests.cs
Comment thread Tests/UnitTestsParallelizable/Views/TextViewTests.cs
Comment thread Tests/UnitTestsParallelizable/Views/TextFieldTests.cs
Comment thread Tests/UnitTestsParallelizable/Views/TextFieldTests.cs
tig and others added 3 commits March 11, 2026 12:55
…ssertion

- Rename CtrlY→CtrlV in clipboard test names/comments (paste is now Ctrl+V)
- Rename CtrlR→CtrlY in redo test name/comment (redo is now Ctrl+Y)
- Replace var with explicit types (TextField/TextView) per repo style
- Add Assert.DoesNotContain(Command.PageDown) to CtrlV paste test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a new TextViewCommandTests class covering all public command methods (DeleteAll, SelectAll, DeleteCharLeft, DeleteCharRight, Copy, Cut, Paste, Undo, Redo) including keyboard bindings, edge cases, and event checks. Refactors DeleteAll to use SelectAll for simpler selection logic. Tests ensure correct behavior for selections, multi-line text, read-only mode, undo/redo, and event raising.
Replaces the DeleteAll command shortcut from Ctrl+Shift+D to Ctrl+Shift+Delete in both TextField and TextView. Updates all related documentation and unit tests to reflect the new key binding. Improves XML docs with detailed key binding tables and clarifies shortcut descriptions. In TextView, Ctrl+Shift+Delete now triggers DeleteAll instead of CutToEndOfLine. Ensures consistency across code, docs, and tests.
@tig
Copy link
Copy Markdown
Collaborator

tig commented Mar 11, 2026

@BDisp There's a problem: By default Shift-ctrl-d in WT is "duplicate terminal". I've changed the default to shift-ctrl-del.

@BDisp
Copy link
Copy Markdown
Collaborator

BDisp commented Mar 11, 2026

@BDisp There's a problem: By default Shift-ctrl-d in WT is "duplicate terminal". I've changed the default to shift-ctrl-del.

Good choice. It's not a problem at all.

@tig
Copy link
Copy Markdown
Collaborator

tig commented Mar 11, 2026

As part o this PR, i've updated all the XML API docs for all views to have consistent key/mouse binding docs:

image

tig added 3 commits March 11, 2026 13:49
Added detailed XML documentation to many Terminal.Gui view classes describing their default key and mouse bindings in a consistent, tabular format. This improves discoverability and usability for developers. Also made minor summary corrections, standardized table headers, and skipped a problematic test in TextViewTests.cs.
@tig tig merged commit 8188498 into v2_develop Mar 11, 2026
11 checks passed
@tig tig deleted the copilot/unify-textfield-textview-keybindings branch March 11, 2026 20:01
tig added a commit that referenced this pull request Mar 11, 2026
- Phase 0 (prerequisite #4828): merged
- Phase 1 (revert POC): done
- Phase 2 (Configuration trace #4827): merged
- Add Phase 1b: rebind DeleteAll from Ctrl+Shift+D to Ctrl+Shift+Delete
- Update all plan references accordingly

Co-Authored-By: Claude Opus 4.6 <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.

Unify TextField and TextView Undo/Redo/Paste key bindings

4 participants