diff --git a/packages/tui/src/components/editor.ts b/packages/tui/src/components/editor.ts index 67ea7e52..4374775d 100644 --- a/packages/tui/src/components/editor.ts +++ b/packages/tui/src/components/editor.ts @@ -333,8 +333,8 @@ export class Editor implements Component { // Left this.moveCursor(0, -1); } - // Regular characters (printable ASCII) - else { + // Regular characters (printable characters and unicode, but not control characters) + else if (data.charCodeAt(0) >= 32) { this.insertCharacter(data); } } @@ -472,7 +472,7 @@ export class Editor implements Component { // Filter out non-printable characters except newlines const filteredText = tabExpandedText .split("") - .filter((char) => char === "\n" || char.length > 0) + .filter((char) => char === "\n" || char.charCodeAt(0) >= 32) .join(""); // Split into lines