F3: suspended Phpactor start, ConPTY shell in a job, cancel superseded completions, syntax proptest
- lutra_proc::spawn_suspended: CREATE_SUSPENDED, join the kill-on-close job, resume via a Tool Help thread snapshot. Opt-in for long-lived children (Phpactor); git, php -l and the probe keep spawn because the snapshot costs ~60 ms per start. - lutra_proc::adopt + Guard (Windows): the terminal's ConPTY shell joins a job, so processes it started end with the tab or with Lutra. - lsp.completion cancels the previous pending completion on the same server ($/cancelRequest); the cancelled command resolves empty. - Syntax proptests compare leaf kinds, outline and folding instead of the S-expression (tree-sitter-php 0.25.1 keeps a union_type wrapper after an undo); Malte's seed added. - docs/development.md: data dirs, target dir inside the repo, parallel builds, deleting ui/node_modules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7ad3005217
commit
ebbc89832c
17 changed files with 468 additions and 36 deletions
|
|
@ -6,3 +6,4 @@
|
|||
# everyone who runs the test benefits from these saved cases.
|
||||
cc c8b0a3ee622e3fac3ec69a94aebc22f23c9b3870156159ba6d9c2c5387d5eced # shrinks to fixture = Index(0), steps = [[(5318099958520493566, 19, 12), (10643632058251538265, 19, 18)], [(11062977690082286900, 37, 1)], [(3728561719478013405, 20, 10)]]
|
||||
cc 3129b8640200f6a3b49b6579ba02346c578c68a5fb37bf929f93fb1aa0f4ef9b # shrinks to fixture = Index(14757395258967641293), steps = [[(14373769676898819633, 13, 21)], [(0, 0, 0)]]
|
||||
cc 4efe36814ff9aa1f8c9bdc1fad55604ae0481a45732032f1c02d772977c1be4b # shrinks to fixture = Index(0), seeds = [(8685451444708560058, 1, 15)]
|
||||
|
|
|
|||
|
|
@ -3,9 +3,17 @@
|
|||
//!
|
||||
//! tree-sitter recovers from syntax errors heuristically, and the recovery
|
||||
//! may differ between an incremental and a fresh parse of the same broken
|
||||
//! text. Tree equality is therefore asserted whenever the edited text
|
||||
//! parses without errors, and an undo round trip must always end at the
|
||||
//! fresh tree of the (error-free) original.
|
||||
//! text. Equality is therefore asserted whenever the edited text parses
|
||||
//! without errors, and an undo round trip must always end at the fresh
|
||||
//! result of the (error-free) original.
|
||||
//!
|
||||
//! Equality means the same outline, the same folding ranges and the same
|
||||
//! sequence of leaf node kinds, not the same S-expression: an incremental
|
||||
//! reparse may reuse a node where a fresh parse picks another wrapper for
|
||||
//! the same tokens (tree-sitter-php 0.25.1 keeps `(union_type
|
||||
//! (primitive_type))` for `array &$cache` after an undo, a fresh parse gives
|
||||
//! `(primitive_type)`). Every structural feature Lutra builds on the tree
|
||||
//! reads outline, folding or leaves, so wrapper nodes may differ.
|
||||
|
||||
#![allow(
|
||||
clippy::unwrap_used,
|
||||
|
|
@ -87,6 +95,18 @@ fn edit_for(text: &str, (start, len, fragment): (usize, usize, usize)) -> Edit {
|
|||
Edit::replace(start..end.max(start), FRAGMENTS[fragment])
|
||||
}
|
||||
|
||||
/// The kinds of the named leaf nodes of `tree`, in document order, read
|
||||
/// from its S-expression: a leaf is a node that closes right after its kind.
|
||||
fn leaf_kinds(tree: &lutra_syntax::Tree) -> Vec<String> {
|
||||
let sexp = tree.to_sexp().replace('(', " ( ").replace(')', " ) ");
|
||||
let tokens: Vec<&str> = sexp.split_whitespace().collect();
|
||||
tokens
|
||||
.windows(3)
|
||||
.filter(|window| window[0] == "(" && window[2] == ")")
|
||||
.map(|window| window[1].to_owned())
|
||||
.collect()
|
||||
}
|
||||
|
||||
proptest! {
|
||||
#![proptest_config(ProptestConfig::with_cases(256))]
|
||||
|
||||
|
|
@ -134,7 +154,7 @@ proptest! {
|
|||
let _ = outline(&tree);
|
||||
let _ = folding(&tree);
|
||||
if !fresh.has_errors() {
|
||||
prop_assert_eq!(tree.to_sexp(), fresh.to_sexp());
|
||||
prop_assert_eq!(leaf_kinds(&tree), leaf_kinds(&fresh));
|
||||
prop_assert_eq!(outline(&tree), outline(&fresh));
|
||||
prop_assert_eq!(folding(&tree), folding(&fresh));
|
||||
}
|
||||
|
|
@ -166,7 +186,7 @@ proptest! {
|
|||
}
|
||||
prop_assert_eq!(tree.text().text(), original);
|
||||
if !expected.has_errors() {
|
||||
prop_assert_eq!(tree.to_sexp(), expected.to_sexp());
|
||||
prop_assert_eq!(leaf_kinds(&tree), leaf_kinds(&expected));
|
||||
prop_assert_eq!(outline(&tree), outline(&expected));
|
||||
prop_assert_eq!(folding(&tree), folding(&expected));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue