Skip to content

Commit

Permalink
fix: cy freezing on (cy/set :animate :true)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Feb 9, 2024
1 parent e1caf8b commit 191f8e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/cy/docs-cy.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Get the value of the [parameter](./parameters.md) with key `key`.

(cy/set key value)

Set the value of the [parameter](./parameters.md) with key `key` to value `value`.
Set the value of the [parameter](./parameters.md) with key `key` to value `value`. For the time being, parameter values can only be strings, booleans, and integers. This is expected to change in the future.

# doc: Replay

Expand Down
18 changes: 9 additions & 9 deletions pkg/cy/janet.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ func (c *CyModule) Get(user interface{}, key *janet.Value) (interface{}, error)
func (c *CyModule) Set(user interface{}, key *janet.Value, value *janet.Value) error {
defer key.Free()

client, ok := user.(*Client)
if !ok {
return fmt.Errorf("missing client context")
}

node := client.Node()
if node == nil {
return fmt.Errorf("client was not attached")
// If there is no client, this probably means a parameter is being set
// in cy's startup script.
var node tree.Node = c.cy.tree.Root()
if client, ok := user.(*Client); ok {
node = client.Node()
if node == nil {
return fmt.Errorf("client was not attached")
}
}

var keyword janet.Keyword
Expand All @@ -133,7 +133,7 @@ func (c *CyModule) Set(user interface{}, key *janet.Value, value *janet.Value) e
return nil
}

var _bool int
var _bool bool
err = value.Unmarshal(&_bool)
if err == nil {
node.Params().Set(string(keyword), _bool)
Expand Down

0 comments on commit 191f8e4

Please sign in to comment.