feat(editor): add incremental forward and reverse search - #184
Merged
Conversation
Greptile SummaryThis PR adds incremental forward and reverse literal search while retaining named immediate-search and repeat commands.
Confidence Score: 5/5The PR appears safe to merge with no concrete correctness, security, or repository-rule violations identified. Search matching, input lifecycle, command compatibility, View restoration, and match rendering are internally consistent and covered by focused boundary and integration tests; no actionable failure remains.
|
| Filename | Overview |
|---|---|
| src/search.rs | Adds streaming forward/reverse literal matching and incremental-search state with overlap and wrap handling. |
| src/app.rs | Integrates search input, paste, cancellation, acceptance, command dispatch, and rendering into application state. |
| src/renderer.rs | Adds active-match styling using absolute character ranges and complete-grapheme rendering. |
| src/command_registry.rs | Makes forward search argument-optional and registers the reverse-search command. |
| src/keymap.rs | Binds C-s and C-r to forward and reverse incremental search. |
| src/buffer.rs | Replaces whole-buffer forward-search materialization with the shared streaming matcher. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[C-s / C-r or named command] --> B{Literal argument supplied?}
B -- Yes --> C[Run immediate directional search]
B -- No --> D[Create IncrementalSearch]
D --> E{Input}
E -- Character / paste / backspace --> F[Update query]
F --> G[Stream Rope through directional KMP]
G --> H{Match found?}
H -- Yes --> I[Move View point and highlight range]
H -- No --> J[Keep last useful point and show no match]
E -- C-s / C-r --> K[Advance directionally with overlap and wrap]
K --> G
E -- Enter / other command --> L[Accept search]
E -- Escape / C-g --> M[Restore original point and scroll]
L --> N[Dispatch other command when applicable]
Reviews (1): Last reviewed commit: "feat(editor): add incremental forward an..." | 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.
C-s and C-r now open incremental literal search in either direction.
Typing and prompt paste update the query, move to a visible match, and leave buffer text and history intact.
Repeat advances through overlapping matches and wraps once, Enter accepts, and Escape/C-g restores the original point and both scroll offsets.
Cancellation also clears a pending clipboard prefix.
No-match feedback preserves the last useful point, and other editor commands accept search before dispatching normally.
The matcher streams Rope characters with memory proportional to query length instead of copying the buffer on each keystroke.
The current match gets a distinct background across complete graphemes, horizontal scrolling, and resize.
Existing named literal search and repeat aliases remain available; search-backward is also registered.
Verification: 408 unit tests pass (four existing diagnostics ignored), formatting, strict Clippy across all targets, and release build pass.
The release PTY workflow covers forward/reverse search, match colour, repeat/wrap, no-match recovery, cancellation including pending clipboard prefixes, accept, literal prompt paste, command dispatch, combining-character matches, save, quit, and shell restoration.
The existing release diagnostic completed 50 searches of a roughly 1.8 MB buffer in 273 ms.
Independent review approved after its cancellation finding was reproduced and fixed.
Eleven of thirteen terminal tests pass locally; the two unchanged redirected-input tests encounter the documented sandbox restrictions and run in macOS CI.
Closes #29.