mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Have lite-parse complete return a complete bare form. (#2389)
Previously, lite parse would stack up opening delimiters in vec, and if we didn't close everything off, it would simply return an error with a partial form that didn't include the missing closing delimiters. This commits adds those delimiters so that `classify_block` can parse correctly.
This commit is contained in:
@ -270,8 +270,13 @@ mod tests {
|
||||
registry: &dyn SignatureRegistry,
|
||||
pos: usize,
|
||||
) -> Vec<LocationType> {
|
||||
let lite_block = lite_parse(line, 0).expect("lite_parse");
|
||||
let lite_block = match lite_parse(line, 0) {
|
||||
Ok(v) => v,
|
||||
Err(e) => e.partial.expect("lite_parse result"),
|
||||
};
|
||||
|
||||
let block = classify_block(&lite_block, registry);
|
||||
|
||||
super::completion_location(line, &block.block, pos)
|
||||
.into_iter()
|
||||
.map(|v| v.item)
|
||||
@ -338,6 +343,17 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_incomplete_nested_structure() {
|
||||
let registry: VecRegistry = vec![Signature::build("sys")].into();
|
||||
let line = "echo $(sy";
|
||||
|
||||
assert_eq!(
|
||||
completion_location(line, ®istry, 8),
|
||||
vec![LocationType::Command],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_flags_with_just_a_single_hyphen() {
|
||||
let registry: VecRegistry = vec![Signature::build("du")
|
||||
|
Reference in New Issue
Block a user