Fix emoji rendering artifacts in terminal
- Activate Unicode 11 in XTerm to prevent double-width overlap - Remove latin1 fallback that breaks multi-byte UTF-8 - Rely on SSH env configuration for proper locale handling Fixes #266
This commit is contained in:
@@ -427,18 +427,7 @@ wss.on("connection", async (ws: WebSocket, req) => {
|
||||
sshStream = stream;
|
||||
|
||||
stream.on("data", (data: Buffer) => {
|
||||
let decoded = data.toString("utf-8");
|
||||
|
||||
// Defensive fallback: if UTF-8 decode produces replacement characters
|
||||
// and buffer contains high bytes, try latin1 (for legacy servers without UTF-8 locale)
|
||||
if (
|
||||
decoded.includes("\uFFFD") &&
|
||||
data.some((byte) => byte >= 0x80 && byte <= 0xff)
|
||||
) {
|
||||
decoded = data.toString("latin1");
|
||||
}
|
||||
|
||||
ws.send(JSON.stringify({ type: "data", data: decoded }));
|
||||
ws.send(JSON.stringify({ type: "data", data: data.toString("utf-8") }));
|
||||
});
|
||||
|
||||
stream.on("close", () => {
|
||||
|
||||
@@ -532,6 +532,10 @@ export const Terminal = forwardRef<any, SSHTerminalProps>(function SSHTerminal(
|
||||
terminal.loadAddon(clipboardAddon);
|
||||
terminal.loadAddon(unicode11Addon);
|
||||
terminal.loadAddon(webLinksAddon);
|
||||
|
||||
// Activate Unicode 11 for proper emoji rendering (prevents double-width artifacts)
|
||||
terminal.unicode.activeVersion = "11";
|
||||
|
||||
terminal.open(xtermRef.current);
|
||||
|
||||
const element = xtermRef.current;
|
||||
|
||||
@@ -233,6 +233,10 @@ export const Terminal = forwardRef<any, SSHTerminalProps>(function SSHTerminal(
|
||||
terminal.loadAddon(clipboardAddon);
|
||||
terminal.loadAddon(unicode11Addon);
|
||||
terminal.loadAddon(webLinksAddon);
|
||||
|
||||
// Activate Unicode 11 for proper emoji rendering (prevents double-width artifacts)
|
||||
terminal.unicode.activeVersion = "11";
|
||||
|
||||
terminal.open(xtermRef.current);
|
||||
|
||||
const textarea = xtermRef.current.querySelector(
|
||||
|
||||
Reference in New Issue
Block a user