Skip to content

Commit

Permalink
fix cursor dec not applying contextual indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dm0n3y committed Jul 2, 2024
1 parent 805b02c commit c81fc75
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
11 changes: 6 additions & 5 deletions src/core/layout/Layout.re
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ let path_of_loc =
};
// todo: reorg this as unzipping layout zipper
let rec state_of_path =
(~state=State.init, ~tree: Tree.t, path: Path.t): State.t =>
(~state=State.init, ~tree: Tree.t, path: Path.t)
: (State.t, option(Tree.t)) =>
switch (path) {
| [] => state
| [] => (state, Some(tree))
// let s_end = State.jump_block(state, ~over=Tree.flatten(tree));
// (state.ind, (state.loc, s_end.loc));
| [hd, ...tl] =>
Expand All @@ -145,13 +146,13 @@ let rec state_of_path =
| Link((pre, b_tok, _)) =>
let state = State.jump_block(state, ~over=Tree.flatten_chain(pre));
switch (tl) {
| [] => state
| [] => (state, None)
// let s_end = State.jump_block(state, ~over=b_tok);
// (state.ind, (state.loc, s_end.loc));
| [hd, ..._] =>
let loc = loc_of_step(~state, ~block=b_tok, hd);
// (state.ind, (loc, loc));
{...state, loc};
({...state, loc}, None);
};
}
};
Expand All @@ -160,7 +161,7 @@ let rec state_of_path =
// Dir.pick(side, (fst, snd), snd(range_of_path(~state, ~tree, path)));

let map = (~tree: Tree.t, f: Loc.t => Loc.t, path: Path.t): Path.t =>
switch (path_of_loc(~tree, f(state_of_path(~tree, path).loc))) {
switch (path_of_loc(~tree, f(fst(state_of_path(~tree, path)).loc))) {
| Ok(path) => path
| Error(_) => Tree.end_path(tree, ~side=R)
};
Expand Down
17 changes: 8 additions & 9 deletions src/web/view/Code.re
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ let cursor = (~font, z: Zipper.t) =>
print_endline("0");
[];
| Point(_) =>
let tree = Layout.Tree.of_cell(Zipper.zip(~save_cursor=true, z));
let (cell, ctx) = Zipper.zip_indicated(z);
switch (Cell.get(cell)) {
| Some(m) when !Cell.Space.is_space(cell) =>
let lyt = Layout.Tree.of_meld(m);
let state =
Layout.state_of_path(
~tree=Layout.Tree.of_cell(Zipper.zip(~save_cursor=true, z)),
Zipper.path_of_ctx(ctx),
);
Dec.Meld.(mk(~font, Profile.mk(~state, lyt, m)));
switch (Layout.state_of_path(~tree, Zipper.path_of_ctx(ctx))) {
| (state, Some(t)) =>
switch (Cell.get(cell), t) {
| (Some(m), Some(lyt)) when !Cell.Space.is_space(cell) =>
Dec.Meld.(mk(~font, Profile.mk(~state, lyt, m)))
| _ => []
}
| _ => []
};
};
Expand Down

0 comments on commit c81fc75

Please sign in to comment.