mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 04:02:21 +00:00
refactor(tui): Use explicit charCode check for unicode filtering
- Use 'charCodeAt(0) >= 32' instead of open 'else' in handleInput() - Use same filter in handlePaste() for consistency - Prevents control characters while allowing all unicode - More explicit and safer than accepting everything
This commit is contained in:
parent
4a83da00c4
commit
3b6ef6cf57
1 changed files with 3 additions and 3 deletions
|
|
@ -333,8 +333,8 @@ export class Editor implements Component {
|
||||||
// Left
|
// Left
|
||||||
this.moveCursor(0, -1);
|
this.moveCursor(0, -1);
|
||||||
}
|
}
|
||||||
// Regular characters (printable ASCII)
|
// Regular characters (printable characters and unicode, but not control characters)
|
||||||
else {
|
else if (data.charCodeAt(0) >= 32) {
|
||||||
this.insertCharacter(data);
|
this.insertCharacter(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -472,7 +472,7 @@ export class Editor implements Component {
|
||||||
// Filter out non-printable characters except newlines
|
// Filter out non-printable characters except newlines
|
||||||
const filteredText = tabExpandedText
|
const filteredText = tabExpandedText
|
||||||
.split("")
|
.split("")
|
||||||
.filter((char) => char === "\n" || char.length > 0)
|
.filter((char) => char === "\n" || char.charCodeAt(0) >= 32)
|
||||||
.join("");
|
.join("");
|
||||||
|
|
||||||
// Split into lines
|
// Split into lines
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue