Skip to content

Commit

Permalink
fix broken delete in middle of keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
dm0n3y committed Nov 12, 2024
1 parent 81d521b commit ae62cde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/editor/Modify.re
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/core/structure/Token.re
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ae62cde

Please sign in to comment.