From ae62cde0876ec2ceff708f5a01c536387664384f Mon Sep 17 00:00:00 2001 From: David Moon Date: Tue, 12 Nov 2024 03:11:23 -0500 Subject: [PATCH] fix broken delete in middle of keywords --- src/core/editor/Modify.re | 3 ++- src/core/structure/Token.re | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/editor/Modify.re b/src/core/editor/Modify.re index 74646a08..babbd25a 100644 --- a/src/core/editor/Modify.re +++ b/src/core/editor/Modify.re @@ -284,7 +284,8 @@ let delete_toks = // note: affixes empty if token completely selected // (assuming edge carets have been temporarily non-normally placed on toks) let (l, r) = Token.(affix(~side=L, tok), affix(~side=R, tok)); - {...tok, text: l ++ r} + let text = Token.is_const(tok) ? l : l ++ r; + {...tok, text} |> Token.put_cursor(Point(Step.Caret.focus(Utf8.length(l)))); } else if (i == 0) { let l = Token.affix(~side=L, tok); diff --git a/src/core/structure/Token.re b/src/core/structure/Token.re index dda98a51..06d1af73 100644 --- a/src/core/structure/Token.re +++ b/src/core/structure/Token.re @@ -44,6 +44,11 @@ module Molded = { [@deriving (sexp, yojson)] type t = Base.t(Mtrl.T.t); + let is_const = (tok: t) => + switch (tok.mtrl) { + | Tile((Const(_), _)) => true + | _ => false + }; let focus_point: t => t = map_marks(Marks.focus_point); let pp = (out, tok: t) => switch (tok.mtrl) {