Skip to content

Commit

Permalink
fix #44
Browse files Browse the repository at this point in the history
  • Loading branch information
dm0n3y committed Nov 5, 2024
1 parent 9658124 commit 0a5d927
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/core/editor/Modify.re
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ let relabel =
(normalized, Ctx.button(rest));
};

// None means token was removed
// None means token was removed. Some(ctx) means token was molded (or deferred and tagged as an unmolded space), ctx includes the molded token.
let mold =
(ctx: Ctx.t, ~fill=Cell.dirty, tok: Token.Unmolded.t): option(Ctx.t) => {
open Options.Syntax;
Expand Down Expand Up @@ -481,6 +481,8 @@ let insert = (s: string, z: Zipper.t) => {
| Some(ctx) =>
let (face, rest) = Ctx.pull(~from=L, ctx);
switch (face, next_fill.marks.cursor) {
// if molded token is longer than original, then move cursor out of
// next_fill and into molded token at the end of its text
| (Node(molded), Some(Point({hand, path: []})))
when Token.length(molded) > Token.Unmolded.length(tok) =>
let marks = {...next_fill.marks, cursor: None};
Expand Down
7 changes: 6 additions & 1 deletion src/core/structure/Token.re
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,12 @@ module Unmolded = {
Base.mk(~id?, ~text, ~marks?, mtrl);
let length = (tok: t) => Utf8.length(tok.text);
let defer = (tok: t): Molded.t =>
Molded.mk(~id=tok.id, ~text=tok.text, Space(Unmolded));
Molded.mk(
~id=tok.id,
~marks=?tok.marks,
~text=tok.text,
Space(Unmolded),
);
let has_lbl = (lbl: Label.t, tok: t) =>
switch (tok.mtrl) {
| Space(_)
Expand Down

0 comments on commit 0a5d927

Please sign in to comment.