Skip to content

Commit

Permalink
Improve backspace handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cowuake committed Apr 30, 2024
1 parent 5992565 commit 7b0e0e0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions schemius-web/schemius.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ class Schemius {

static handleDelete() {
const position = Schemius.terminal.get_position();
const char = Schemius.terminal.cmd().get()[position - 1];
const picker = Schemius.terminal.cmd().get();
const [precedingChar, followingChar] = [picker[position - 1], picker[position]];
const match = Schemius.matchingChars[precedingChar];

if (
Schemius.matchingChars[char] &&
Schemius.terminal.cmd().get()[position] === Schemius.matchingChars[char]
) {
Schemius.terminal.cmd().delete(-1);
if (match && followingChar === match) {
Schemius.terminal.cmd().delete(1);
}
}
Expand Down Expand Up @@ -280,6 +280,7 @@ class Schemius {
return false;
} else if (e.key === "BACKSPACE") {
Schemius.handleDelete();
return false;
} else if (e.isComposing || e.keyCode === 229) {
// Handle keydown events during IME composition
if (Schemius.isMobile()) {
Expand Down

0 comments on commit 7b0e0e0

Please sign in to comment.