Skip to content

Commit

Permalink
fix structured editor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
CrowdHailer committed Aug 24, 2024
1 parent f826380 commit df23917
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions eyg/src/morph/editable.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,9 @@ pub fn to_annotated(source, rev) {
let #(i, acc) = acc
let i = i - 2
let #(label, value) = field
let value = to_annotated(value, [i, ..rev])
let value = to_annotated(value, [i + 1, ..rev])
#(i, #(
a.Apply(#(a.Apply(#(build(label), rev), value), rev), acc),
a.Apply(#(a.Apply(#(build(label), [i, ..rev]), value), rev), acc),
rev,
))
})
Expand Down
14 changes: 12 additions & 2 deletions eyg/src/morph/lustre/render.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,11 @@ fn render_break(break, inner, is_expression) {
let top = expression(top)
let pre = list.map(pre, render_branch)
let post = list.map(post, render_branch)
let branch = frame.prepend_spans([text(label), text(" ")], inner)
let branch =
frame.prepend_spans(
[h.span([a.class("text-blue-700")], [text(label), text(" ")])],
inner,
)
let otherwise = option.map(otherwise, expression)

render_case(top, listx.gather_around(pre, branch, post), otherwise)
Expand Down Expand Up @@ -514,7 +518,13 @@ pub fn projection(zip, is_expression) -> element.Element(a) {
t.Match(top, label, value, pre, post, otherwise) -> {
let value = expression(value)
let branch =
frame.prepend_spans([highlight.spans([text(label)]), text(" ")], value)
frame.prepend_spans(
[
highlight.spans([h.span([a.class("text-blue-700")], [text(label)])]),
text(" "),
],
value,
)
let pre = list.map(pre, render_branch)
let post = list.map(post, render_branch)
render_case(
Expand Down
2 changes: 1 addition & 1 deletion eyg/src/morph/navigation.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub fn zoom_next(exp, zoom) {
do_first(#(p.Exp(next), zoom))
}
p.ListItem(pre, [], Some(tail)) -> {
let zoom = [p.ListTail(list.reverse([exp, ..pre]))]
let zoom = [p.ListTail(list.reverse([exp, ..pre])), ..rest]
do_first(#(p.Exp(tail), zoom))
}
p.ListItem(pre, [], None) -> {
Expand Down

0 comments on commit df23917

Please sign in to comment.