Skip to content

feat(editor): add typing and region indentation - #178

Merged
owainlewis merged 1 commit into
mainfrom
codex/issue-164-indentation
Sep 8, 2026
Merged

feat(editor): add typing and region indentation#178
owainlewis merged 1 commit into
mainfrom
codex/issue-164-indentation

Conversation

@owainlewis

Copy link
Copy Markdown
Owner

Tab now inserts spaces to the next four-column stop, and Enter carries leading spaces/tabs while preserving LF or CRLF style.
Tab and Shift-Tab indent or outdent selected lines as one undo step, preserving selection direction and excluding an end at the next line's start.
Shift-Tab without a region removes up to four columns of leading indentation.
Named indent and outdent commands share these behaviors.

Single-line operations change only the whitespace prefix, so a long line does not create full-line undo copies.
Closes #164.

Verification:

  • 352 unit tests pass, covering Unicode display width/graphemes, existing tabs, newline style and split points, forward/reverse regions, blank lines, undo/redo, and bounded single-line history payload.
  • Eight terminal integration tests pass locally; the two redirected-input cases remain restricted by the local sandbox and require the existing GitHub checks.
  • Formatting, all-target Clippy, and release build pass.
  • Release PTY flow: nested Rust typing, region indent/outdent, undo/redo across saves, clean exit, restored terminal settings, and usable shell.
  • Independent review: Approve.

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds indentation-aware typing and region editing while preserving editor history, selection direction, grapheme boundaries, and existing newline conventions.

  • Tab inserts spaces to the next four-column display stop.
  • Enter carries the available leading indentation and preserves LF or CRLF style.
  • Tab and Shift-Tab indent or outdent selected lines as one undoable edit.
  • Named indentation commands share keyboard behavior.
  • Focused tests cover Unicode, mixed whitespace, region boundaries, line endings, history size, and undo/redo.

Confidence Score: 5/5

The PR appears safe to merge; no actionable correctness, security, or repository-rule issues remain.

The command paths, prefix-only text replacement, point and mark mapping, newline fallback behavior, and mixed-whitespace handling are internally consistent and supported by focused tests.

Important Files Changed

Filename Overview
src/commands.rs Implements newline indentation, tab-stop insertion, prefix-only outdent, region replacement, endpoint mapping, and focused behavioral tests.
src/app.rs Routes keyboard and named indentation commands through shared region-aware behavior while preserving selection direction.
src/buffer.rs Adds bounded indentation and newline-style queries and exposes point-aware replacement for compact undo records.
src/input.rs Adds constrained conversion of terminal BackTab events into the editor’s Shift-Tab key.
src/keymap.rs Maps Tab and BackTab to the new indentation commands.
src/command_registry.rs Registers named indent and outdent commands and updates newline command documentation.
README.md Documents tab stops, carried indentation, line-ending preservation, region behavior, and named commands.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Keyboard or named command] --> B{Indent or Outdent?}
  B -->|No active region| C[Dispatch single-line command]
  C --> D{Indent?}
  D -->|Yes| E[Insert spaces to next tab stop]
  D -->|No| F[Remove up to four leading columns]
  B -->|Active region| G[Normalize selected line range]
  G --> H[Exclude endpoint at next line start]
  H --> I[Replace changed prefixes as one edit]
  I --> J[Map point and mark through edit]
  J --> K[Preserve selection direction]
Loading

Reviews (1): Last reviewed commit: "feat(editor): add typing and region inde..." | Re-trigger Greptile

@owainlewis
owainlewis merged commit 9d10d71 into main Sep 8, 2026
2 checks passed
@owainlewis
owainlewis deleted the codex/issue-164-indentation branch September 8, 2026 18:24
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.

Add practical indentation for typing and selected lines

1 participant