Basic search mechanism in editor

This commit is contained in:
2026-01-26 01:25:40 +01:00
parent 2453b78237
commit 2235a4b0a1
4 changed files with 141 additions and 17 deletions

View File

@@ -385,10 +385,23 @@ fn handle_modal_input(ctx: &mut InputContext, key: KeyEvent) -> InputResult {
},
Modal::Editor => {
let ctrl = key.modifiers.contains(KeyModifiers::CONTROL);
let editor = &mut ctx.app.editor_ctx.editor;
if editor.search_active() {
match key.code {
KeyCode::Esc => editor.search_clear(),
KeyCode::Enter => editor.search_confirm(),
KeyCode::Backspace => editor.search_backspace(),
KeyCode::Char(c) if !ctrl => editor.search_input(c),
_ => {}
}
return InputResult::Continue;
}
match key.code {
KeyCode::Esc => {
if ctx.app.editor_ctx.editor.completion_active() {
ctx.app.editor_ctx.editor.dismiss_completion();
if editor.completion_active() {
editor.dismiss_completion();
} else {
ctx.dispatch(AppCommand::SaveEditorToStep);
ctx.dispatch(AppCommand::CompileCurrentStep);
@@ -399,8 +412,17 @@ fn handle_modal_input(ctx: &mut InputContext, key: KeyEvent) -> InputResult {
ctx.dispatch(AppCommand::SaveEditorToStep);
ctx.dispatch(AppCommand::CompileCurrentStep);
}
KeyCode::Char('f') if ctrl => {
editor.activate_search();
}
KeyCode::Char('n') if ctrl => {
editor.search_next();
}
KeyCode::Char('p') if ctrl => {
editor.search_prev();
}
_ => {
ctx.app.editor_ctx.editor.input(Event::Key(key));
editor.input(Event::Key(key));
}
}
}