feat(editor): add typing and region indentation - #178
Merged
Conversation
Greptile SummaryThis PR adds indentation-aware typing and region editing while preserving editor history, selection direction, grapheme boundaries, and existing newline conventions.
Confidence Score: 5/5The 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.
|
| 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]
Reviews (1): Last reviewed commit: "feat(editor): add typing and region inde..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
indentandoutdentcommands 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: