Skip to content

Commit

Permalink
fix: 🐛 improve insert selection ending
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Jul 23, 2024
1 parent 4cce30a commit 40ec457
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/InputEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class InputEditor implements EditorFacade {
let [start, end] = selection;
const length = text.length;
if (start >= position) start += length;
if (end >= position) end += length;
if (end > position) end += length;
this.setSelection(start, end, selection[2]);
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ const Demo: React.FC<{textarea: boolean}> = ({textarea}) => {
Delete 5 chars from model at pos 3 after 2s
</button>
</div>
<div>
<button
onClick={() => {
setTimeout(() => {
const str = model.api.str(['text']);
str.del(1, 1);
}, 2000);
}}
>
Delete second character after 2s
</button>
</div>
<div>
<button
onClick={() => {
Expand Down

0 comments on commit 40ec457

Please sign in to comment.