feat: add execution_filter and suspend_control features #946
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.
Add execution filtering with terminal state management
Summary
This PR adds optional execution filtering that allows REPL applications to intercept commands and decide whether to execute them normally or delegate to external handlers, with proper terminal state management.
Problem
Many REPL applications need to handle different types of commands differently:
Currently, reedline executes all commands the same way, forcing applications to either:
Solution
This PR adds two complementary features (both optional via feature flags):
execution_filter
: Allows applications to filter commands at commit-timesuspend_control
: APIs for proper terminal state management during delegationThe key difference from the existing
ReedlineEvent::ExecuteHostCommand
is that this works automatically based on command content, not requiring explicit user keybindings.Usage Example
Changes
execution_filter
andsuspend_control
ExecutionFilter
trait for command filteringSignal::ExecuteHostCommand
variant (feature-gated)examples/execution_filter.rs
)Impact
Testing
Test Coverage
We've added comprehensive test coverage for all new functionality:
Unit Tests Added (4 new tests, ~85% coverage of testable code):
test_execution_filter_set
- Verifies filter can be set and retrievedtest_execution_filter_logic
- Tests delegation decision logic with multiple scenariostest_suspend_and_resume
- Tests suspend/resume state management cyclestest_filter_integration_with_suspend
- Tests integration between featuresCoverage Breakdown:
force_repaint
(requires terminal)Running Tests
All existing tests continue to pass (511 tests with our features enabled), with 4 new tests added specifically for the new functionality.
Notes
#[non_exhaustive]
would prevent this issue for future additions.Compatibility
execution_filter
feature is explicitly enabled