mirror of
https://github.com/typst/typst
synced 2025-06-22 21:32:52 +08:00
Fix param autocompletion false positive (#6475)
This commit is contained in:
parent
f1c761e88b
commit
f364b3c323
@ -701,7 +701,10 @@ fn complete_params(ctx: &mut CompletionContext) -> bool {
|
|||||||
let mut deciding = ctx.leaf.clone();
|
let mut deciding = ctx.leaf.clone();
|
||||||
while !matches!(
|
while !matches!(
|
||||||
deciding.kind(),
|
deciding.kind(),
|
||||||
SyntaxKind::LeftParen | SyntaxKind::Comma | SyntaxKind::Colon
|
SyntaxKind::LeftParen
|
||||||
|
| SyntaxKind::RightParen
|
||||||
|
| SyntaxKind::Comma
|
||||||
|
| SyntaxKind::Colon
|
||||||
) {
|
) {
|
||||||
let Some(prev) = deciding.prev_leaf() else { break };
|
let Some(prev) = deciding.prev_leaf() else { break };
|
||||||
deciding = prev;
|
deciding = prev;
|
||||||
@ -1734,6 +1737,8 @@ mod tests {
|
|||||||
test("#numbering(\"foo\", 1, )", -2)
|
test("#numbering(\"foo\", 1, )", -2)
|
||||||
.must_include(["integer"])
|
.must_include(["integer"])
|
||||||
.must_exclude(["string"]);
|
.must_exclude(["string"]);
|
||||||
|
// After argument list no completions.
|
||||||
|
test("#numbering()", -1).must_exclude(["string"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Test that autocompletion for values of known type picks up nested
|
/// Test that autocompletion for values of known type picks up nested
|
||||||
@ -1829,17 +1834,17 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_autocomplete_fonts() {
|
fn test_autocomplete_fonts() {
|
||||||
test("#text(font:)", -1)
|
test("#text(font:)", -2)
|
||||||
.must_include(["\"Libertinus Serif\"", "\"New Computer Modern Math\""]);
|
.must_include(["\"Libertinus Serif\"", "\"New Computer Modern Math\""]);
|
||||||
|
|
||||||
test("#show link: set text(font: )", -1)
|
test("#show link: set text(font: )", -2)
|
||||||
.must_include(["\"Libertinus Serif\"", "\"New Computer Modern Math\""]);
|
.must_include(["\"Libertinus Serif\"", "\"New Computer Modern Math\""]);
|
||||||
|
|
||||||
test("#show math.equation: set text(font: )", -1)
|
test("#show math.equation: set text(font: )", -2)
|
||||||
.must_include(["\"New Computer Modern Math\""])
|
.must_include(["\"New Computer Modern Math\""])
|
||||||
.must_exclude(["\"Libertinus Serif\""]);
|
.must_exclude(["\"Libertinus Serif\""]);
|
||||||
|
|
||||||
test("#show math.equation: it => { set text(font: )\nit }", -6)
|
test("#show math.equation: it => { set text(font: )\nit }", -7)
|
||||||
.must_include(["\"New Computer Modern Math\""])
|
.must_include(["\"New Computer Modern Math\""])
|
||||||
.must_exclude(["\"Libertinus Serif\""]);
|
.must_exclude(["\"Libertinus Serif\""]);
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,8 @@ impl WorldLike for &str {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Specifies a position in a file for a test.
|
/// Specifies a position in a file for a test. Negative numbers index from the
|
||||||
|
/// back. `-1` is at the very back.
|
||||||
pub trait FilePos {
|
pub trait FilePos {
|
||||||
fn resolve(self, world: &TestWorld) -> (Source, usize);
|
fn resolve(self, world: &TestWorld) -> (Source, usize);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user