Skip to content

Editor: overwrite / insert-replace mode (Insert key)#156

Merged
tig merged 4 commits into
developfrom
copilot/add-overwrite-mode-editor
May 17, 2026
Merged

Editor: overwrite / insert-replace mode (Insert key)#156
tig merged 4 commits into
developfrom
copilot/add-overwrite-mode-editor

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 17, 2026

Editor is insert-only — no overwrite state, command, or caret style. TextView supports it; it's a widely-expected editor mode and not replicable by a consumer.

Core

  • OverwriteMode property (field-keyword pattern, default off) + OverwriteModeChanged event on Editor
  • Command.ToggleOverwrite / EnableOverwrite / DisableOverwrite wired via AddCommand; Insert key bound in DefaultKeyBindings (user-overridable [ConfigurationProperty])
  • OverwriteAtOffset() helper: replaces the grapheme cluster at caret using RemoveAndInsert offset mapping so the caret anchor advances correctly. Wide-rune safe via StringInfo.GetNextTextElementLength. Falls back to insert at line-end (never consumes newline). Selection still replaces normally.
  • Multi-caret insert path routes through the same overwrite logic per-caret
  • Cursor forced to CursorStyle.SteadyBlock while overwrite is active

ted

  • INS/OVR status-bar indicator, updated on OverwriteModeChanged

Specs

  • specs/overwrite-mode/spec.md created
  • specs/public-api.md updated with new property and event

Tests

  • 11 new integration tests covering: toggle via Insert key, overwrite replacement, line-end insert fallback, selection replacement, single undo step, multi-line newline preservation, Enable/Disable commands
editor.OverwriteMode = true;
// Caret at offset 0, document "abc"
// Type 'x' → document becomes "xbc", caret at 1

Copilot AI assigned Copilot and tig May 17, 2026
Copilot AI linked an issue May 17, 2026 that may be closed by this pull request
6 tasks
Add OverwriteMode property with field-keyword pattern, wire
Command.ToggleOverwrite/EnableOverwrite/DisableOverwrite via
AddCommand and DefaultKeyBindings (Insert key = default toggle).

When overwrite is active and no selection exists and caret is not at
line-end, typing replaces the grapheme under the caret (wide-rune safe
via StringInfo.GetNextTextElementLength). Selection + line-end still
insert. Each overwrite is a single undo step.

Caret renders as SteadyBlock while overwrite is active.
Multi-caret insert path also respects overwrite mode.

ted: INS/OVR status bar indicator.
specs: overwrite-mode/spec.md created; public-api.md updated.
Tests: 11 new integration tests, all green.

Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/e0fe7ce8-4870-47c6-87cf-9bd7b524f8e3

Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copilot AI changed the title [WIP] Add overwrite mode functionality to Editor Editor: overwrite / insert-replace mode (Insert key) May 17, 2026
Copilot finished work on behalf of tig May 17, 2026 14:49
Copilot AI requested a review from tig May 17, 2026 14:49
@tig tig marked this pull request as ready for review May 17, 2026 15:46
Copy link
Copy Markdown

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

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: da7da57c8b

ℹ️ 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.Drawing.cs
@tig tig merged commit cdd90d2 into develop May 17, 2026
8 checks passed
@tig tig deleted the copilot/add-overwrite-mode-editor branch May 17, 2026 18:37
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.

Editor: overwrite / insert-replace mode (Insert key)

2 participants