mirror of
https://github.com/typst/typst
synced 2025-08-23 11:14:13 +08:00
Compare commits
3 Commits
832fab58b3
...
e632bffc2e
Author | SHA1 | Date | |
---|---|---|---|
|
e632bffc2e | ||
|
2a3746c51d | ||
|
df4c08f852 |
@ -298,13 +298,20 @@ fn complete_math(ctx: &mut CompletionContext) -> bool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start of an interpolated identifier: "#|".
|
// Start of an interpolated identifier: "$#|$".
|
||||||
if ctx.leaf.kind() == SyntaxKind::Hash {
|
if ctx.leaf.kind() == SyntaxKind::Hash {
|
||||||
ctx.from = ctx.cursor;
|
ctx.from = ctx.cursor;
|
||||||
code_completions(ctx, true);
|
code_completions(ctx, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Behind existing interpolated identifier: "$#pa|$".
|
||||||
|
if ctx.leaf.kind() == SyntaxKind::Ident {
|
||||||
|
ctx.from = ctx.leaf.offset();
|
||||||
|
code_completions(ctx, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Behind existing atom or identifier: "$a|$" or "$abc|$".
|
// Behind existing atom or identifier: "$a|$" or "$abc|$".
|
||||||
if matches!(
|
if matches!(
|
||||||
ctx.leaf.kind(),
|
ctx.leaf.kind(),
|
||||||
@ -1666,6 +1673,13 @@ mod tests {
|
|||||||
test("#{() .a}", -2).must_include(["at", "any", "all"]);
|
test("#{() .a}", -2).must_include(["at", "any", "all"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Test that autocomplete in math uses the correct global scope.
|
||||||
|
#[test]
|
||||||
|
fn test_autocomplete_math_scope() {
|
||||||
|
test("$#col$", -2).must_include(["colbreak"]).must_exclude(["colon"]);
|
||||||
|
test("$col$", -2).must_include(["colon"]).must_exclude(["colbreak"]);
|
||||||
|
}
|
||||||
|
|
||||||
/// Test that the `before_window` doesn't slice into invalid byte
|
/// Test that the `before_window` doesn't slice into invalid byte
|
||||||
/// boundaries.
|
/// boundaries.
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -114,7 +114,9 @@ pub fn globals<'a>(world: &'a dyn IdeWorld, leaf: &LinkedNode) -> &'a Scope {
|
|||||||
| Some(SyntaxKind::Math)
|
| Some(SyntaxKind::Math)
|
||||||
| Some(SyntaxKind::MathFrac)
|
| Some(SyntaxKind::MathFrac)
|
||||||
| Some(SyntaxKind::MathAttach)
|
| Some(SyntaxKind::MathAttach)
|
||||||
);
|
) && leaf
|
||||||
|
.prev_leaf()
|
||||||
|
.is_none_or(|prev| !matches!(prev.kind(), SyntaxKind::Hash));
|
||||||
|
|
||||||
let library = world.library();
|
let library = world.library();
|
||||||
if in_math {
|
if in_math {
|
||||||
|
@ -549,7 +549,7 @@ impl Gradient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Repeats this gradient a given number of times, optionally mirroring it
|
/// Repeats this gradient a given number of times, optionally mirroring it
|
||||||
/// at each repetition.
|
/// at every second repetition.
|
||||||
///
|
///
|
||||||
/// ```example
|
/// ```example
|
||||||
/// #circle(
|
/// #circle(
|
||||||
@ -564,7 +564,17 @@ impl Gradient {
|
|||||||
&self,
|
&self,
|
||||||
/// The number of times to repeat the gradient.
|
/// The number of times to repeat the gradient.
|
||||||
repetitions: Spanned<usize>,
|
repetitions: Spanned<usize>,
|
||||||
/// Whether to mirror the gradient at each repetition.
|
/// Whether to mirror the gradient at every second repetition, i.e.,
|
||||||
|
/// the first instance (and all odd ones) stays unchanged.
|
||||||
|
///
|
||||||
|
/// ```example
|
||||||
|
/// #circle(
|
||||||
|
/// radius: 40pt,
|
||||||
|
/// fill: gradient
|
||||||
|
/// .conic(green, black)
|
||||||
|
/// .repeat(2, mirror: true)
|
||||||
|
/// )
|
||||||
|
/// ```
|
||||||
#[named]
|
#[named]
|
||||||
#[default(false)]
|
#[default(false)]
|
||||||
mirror: bool,
|
mirror: bool,
|
||||||
|
@ -112,11 +112,18 @@
|
|||||||
a few more functions that create delimiter pairings for absolute, ceiled,
|
a few more functions that create delimiter pairings for absolute, ceiled,
|
||||||
and floored values as well as norms.
|
and floored values as well as norms.
|
||||||
|
|
||||||
|
To prevent a delimiter from being matched by Typst, and thus auto-scaled,
|
||||||
|
escape it with a backslash. To instead disable auto-scaling completely, use
|
||||||
|
`{set math.lr(size: 1em)}`.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
```example
|
```example
|
||||||
$ [a, b/2] $
|
$ [a, b/2] $
|
||||||
$ lr(]sum_(x=1)^n], size: #50%) x $
|
$ lr(]sum_(x=1)^n], size: #50%) x $
|
||||||
$ abs((x + y) / 2) $
|
$ abs((x + y) / 2) $
|
||||||
|
$ \{ (x / y) \} $
|
||||||
|
#set math.lr(size: 1em)
|
||||||
|
$ { (a / b), a, b in (0; 1/2] } $
|
||||||
```
|
```
|
||||||
|
|
||||||
- name: calc
|
- name: calc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user