mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 13:32:45 -05:00
Scripts: stale layers and artboards throw their stale error from index()
layers.index(n) and artboards.index(n) returned Not found for a negative or fractional number before checking whether the collection was stale, so a script holding a stale collection got the wrong error. Both now check the collection first, as the art collections' index() does.
This commit is contained in:
1 parent
3368ac519c
commit
a53165fa85
3 files changed
+28
-5
No files matched your search
@@ -634,8 +634,12 @@ fn layers_by_name(h: &Host, a: &[Data]) -> Answer {
|
||||
fn layers_index(h: &Host, a: &[Data]) -> Answer {
|
||||
match arg(a, 1) {
|
||||
Data::String(_) => layers_by_name(h, a),
|
||||
// A number is a position here, never a name ([`layers_at`]).
|
||||
Data::Number(n) if super::position(*n).is_none() => Err(HostError::Error(NOT_FOUND.into())),
|
||||
// A number is a position here, never a name ([`layers_at`]). A stale collection throws its
|
||||
// stale error first.
|
||||
Data::Number(n) if super::position(*n).is_none() => {
|
||||
layers_scope(h, arg(a, 0))?;
|
||||
Err(HostError::Error(NOT_FOUND.into()))
|
||||
}
|
||||
Data::Number(_) => match layers_at(h, a)? {
|
||||
Data::Undefined => Err(HostError::Error(NOT_FOUND.into())),
|
||||
d => Ok(d),
|
||||
@@ -1479,8 +1483,12 @@ fn boards_by_name(h: &Host, a: &[Data]) -> Answer {
|
||||
fn boards_index(h: &Host, a: &[Data]) -> Answer {
|
||||
match arg(a, 1) {
|
||||
Data::String(_) => boards_by_name(h, a),
|
||||
// A number is a position here, never a name ([`boards_at`]).
|
||||
Data::Number(n) if super::position(*n).is_none() => Err(HostError::Error(NOT_FOUND.into())),
|
||||
// A number is a position here, never a name ([`boards_at`]). A stale collection throws its
|
||||
// stale error first.
|
||||
Data::Number(n) if super::position(*n).is_none() => {
|
||||
boards_doc(h, a)?;
|
||||
Err(HostError::Error(NOT_FOUND.into()))
|
||||
}
|
||||
Data::Number(_) => match boards_at(h, a)? {
|
||||
Data::Undefined => Err(HostError::Error(NOT_FOUND.into())),
|
||||
d => Ok(d),
|
||||
|
||||
Reference in new issue
Block a user