make Backspace delete the current selection correctly (#108)

This commit is contained in:
りき萌 2025-05-26 18:54:14 +02:00
parent 7727e62655
commit c4f6f80166

View file

@ -257,6 +257,9 @@ export class CodeEditor extends HTMLElement {
this.pushHistory({ allowMerge: true });
let selection = this.getSelection();
if (selection.start != selection.end) {
this.replace(selection, "");
} else {
selection.collapse();
let start = getLineStart(this.code, selection.start);
@ -270,8 +273,9 @@ export class CodeEditor extends HTMLElement {
selection.cursor -= charactersToRemove;
selection.clampCursor(this.code);
this.replace(selection, "");
selection.collapse();
}
selection.collapse();
this.setSelection(selection);
}