mirror of
https://github.com/lotabout/skim.git
synced 2026-09-10 07:16:23 -04:00
* Initial commit * Disable Matcher when query is empty * Revert * Cleanup * Use par_chunks for faster search * Cleanup * Skip updating atomic on every iter * Item index unnecessary? * Cleanup * Build thread pool at App level * Initial commit * Disable Matcher when query is empty * Revert * Cleanup * Use par_chunks for faster search * Cleanup * Skip updating atomic on every iter * Item index unnecessary? * Cleanup * Build thread pool at App level * Make suggested improvements * chore: cleanup after rebase * refactor: rewrite insta test harness to use fine-grained Skim:: methods Split `impl Skim` into a generic `impl<Backend> Skim<Backend>` block so that `Skim::init()`, `Skim::start()`, `Skim::tick()`, etc. work with any backend, not just the default CrosstermBackend. New public API on Skim<B>: - `init_tui_with(tui)` – inject a caller-provided TUI (e.g. TestBackend) - `app()` / `app_mut()` – access the application state - `tui_ref()` / `tui_mut()` – access the TUI - `app_and_tui()` – simultaneous mutable access to both (avoids borrow conflicts in render and handle_event calls) - `final_event()` – inspect the quit event TestHarness now wraps `Skim<TestBackend>` and initializes via `Skim::init()` + `Skim::init_tui_with()`, sharing the production init path (theme, reader, command expansion) instead of duplicating it. https://claude.ai/code/session_016PtHKc9YVEpHftDxG5Nger * chore: make insta harness more realistic * Cleanup merge errors * Remove duplicate check * Cleanup * No need to clone twice * fix: fix thread pool race condition --------- Co-authored-by: Loric ANDRE <loric.andre@pm.me> Co-authored-by: Claude <noreply@anthropic.com>
192 lines
4.2 KiB
Rust
192 lines
4.2 KiB
Rust
#[allow(dead_code)]
|
|
#[macro_use]
|
|
mod common;
|
|
|
|
// Basic interactive mode test
|
|
insta_test!(keys_interactive_basic, ["1", "2", "3", "4"], &["-i"], {
|
|
@snap;
|
|
@type "99";
|
|
@snap;
|
|
});
|
|
|
|
// Input navigation keys
|
|
|
|
insta_test!(keys_interactive_arrows, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@key Left;
|
|
@char '|';
|
|
@snap;
|
|
@key Right;
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_ctrl_arrows, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@ctrl Left;
|
|
@char '|';
|
|
@snap;
|
|
@ctrl Left;
|
|
@char '|';
|
|
@snap;
|
|
@ctrl Right;
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_ctrl_a, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@ctrl 'a';
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_ctrl_b, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@ctrl 'a';
|
|
@char '|';
|
|
@snap;
|
|
@ctrl 'f';
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_ctrl_e, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@ctrl 'a';
|
|
@char '|';
|
|
@snap;
|
|
@ctrl 'e';
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_ctrl_f, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@ctrl 'a';
|
|
@char '|';
|
|
@snap;
|
|
@ctrl 'f';
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_ctrl_h, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@ctrl 'h';
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_alt_b, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@alt 'b';
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_alt_f, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@ctrl 'a';
|
|
@char '|';
|
|
@snap;
|
|
@alt 'f';
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
// Input manipulation keys
|
|
|
|
insta_test!(keys_interactive_bspace, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@key Backspace;
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_ctrl_c, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@ctrl 'c';
|
|
@exited 130;
|
|
});
|
|
insta_test!(keys_interactive_ctrl_d, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@ctrl 'd';
|
|
@exited 130;
|
|
});
|
|
|
|
insta_test!(keys_interactive_ctrl_u, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@ctrl 'u';
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_ctrl_w, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@ctrl 'w';
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_ctrl_y, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@alt Backspace;
|
|
@char '|';
|
|
@snap;
|
|
@ctrl 'y';
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_alt_d, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@ctrl Left;
|
|
@char '|';
|
|
@snap;
|
|
@ctrl Left;
|
|
@char '|';
|
|
@snap;
|
|
@alt 'd';
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_alt_bspace, @interactive, &["-i", "--cmd", "true", "--cmd-query", "foo bar foo-bar"], {
|
|
@snap;
|
|
@alt Backspace;
|
|
@char '|';
|
|
@snap;
|
|
});
|
|
|
|
// Results navigation keys
|
|
|
|
insta_test!(keys_interactive_ctrl_k, ["1", "2", "3", "4"], &["-i"], {
|
|
@snap;
|
|
@ctrl 'k';
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_tab, ["1", "2", "3", "4"], &["-i"], {
|
|
@snap;
|
|
@ctrl 'k';
|
|
@snap;
|
|
@key Tab;
|
|
@snap;
|
|
});
|
|
|
|
insta_test!(keys_interactive_btab, ["1", "2", "3", "4"], &["-i"], {
|
|
@snap;
|
|
@key BackTab;
|
|
@snap;
|
|
});
|
|
|
|
// Tests Enter and Ctrl-M for accepting selection
|
|
|
|
insta_test!(keys_interactive_enter, ["1", "2", "3", "4"], &["-i"], {
|
|
@snap;
|
|
@key Enter;
|
|
@assert(|h: &common::insta::TestHarness| h.skim.app().should_quit);
|
|
@assert(|h: &common::insta::TestHarness| h.skim.app().item_list.selected().unwrap().text() == "1");
|
|
});
|