Skip to content

feat: lift IIndentationStrategy and wire auto-indent on Enter#95

Merged
tig merged 2 commits into
developfrom
feature/indentation-model
May 13, 2026
Merged

feat: lift IIndentationStrategy and wire auto-indent on Enter#95
tig merged 2 commits into
developfrom
feature/indentation-model

Conversation

@tig

@tig tig commented May 13, 2026

Copy link
Copy Markdown
Member

Summary

Lifts \IIndentationStrategy\ and \DefaultIndentationStrategy\ from AvaloniaEdit (commit \d7a6b63) into \src/Terminal.Gui.Editor/Indentation/\ (namespace \Terminal.Gui.Text.Indentation). Wires the strategy into the Editor so pressing Enter auto-indents by copying leading whitespace from the previous line.

Implements the \specs/indentation/spec.md\ specification.

Changes

Lifted from AvaloniaEdit

  • *\IIndentationStrategy* — pluggable interface with \IndentLine\ and \IndentLines\
  • *\DefaultIndentationStrategy* — copies leading whitespace from the previous line

Editor integration

  • *\Editor.IndentationStrategy* property — defaults to \DefaultIndentationStrategy; set to
    ull\ to disable auto-indent
  • *\Command.NewLine* handler now calls \IndentationStrategy.IndentLine()\ on the newly created line after inserting the newline

ted (first-class consumer)

  • Options → Auto Indent checkbox — toggles \IndentationStrategy\ between \DefaultIndentationStrategy\ and
    ull\
  • Auto-indent is on by default in ted

Tests

  • \DefaultIndentationStrategyTests\ — copies spaces, tabs, mixed whitespace; no-op on first line; replaces existing whitespace; null checks
  • \EditorAutoIndentTests\ — strategy defaults, null strategy, custom strategy integration

UPSTREAM.md

  • Added \Indentation/\ to lifted folders table
  • Added skip note for \CSharp/\ subfolder
  • Added modification rows for namespace transforms and code modernization

Test results

All 336 tests pass (0 errors, 0 failures).

…t on Enter

Lift IIndentationStrategy and DefaultIndentationStrategy from AvaloniaEdit
(commit d7a6b63) into src/Terminal.Gui.Editor/Indentation/ with namespace
Terminal.Gui.Text.Indentation. The default strategy copies leading whitespace
from the previous line when Enter is pressed.

- Add Editor.IndentationStrategy property (defaults to DefaultIndentationStrategy)
- Wire Command.NewLine to call IndentLine on the new line after insertion
- Add Auto Indent toggle to ted's Options menu (first-class consumer)
- Add unit tests for DefaultIndentationStrategy and Editor auto-indent integration
- Update UPSTREAM.md with Indentation/ lift and modification log
- Skip CSharp/ subfolder (language-specific strategies are out of scope)

Closes #TBD

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tig tig force-pushed the feature/indentation-model branch from e79ef10 to 70a1e4a Compare May 13, 2026 05:40

@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: 70a1e4aa56

ℹ️ 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
The newline insertion and IndentLine call are now inside a single
RunUpdate scope so Ctrl+Z undoes both in one step, matching the
pre-auto-indent Enter behavior.

Addresses PR #95 review feedback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tig tig merged commit ad4f41c into develop May 13, 2026
8 checks passed
@tig tig deleted the feature/indentation-model branch May 13, 2026 06:04
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.

1 participant