дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
fix(terminal): give wide emoji two columns (#7548)
Terminals and embedded terminals load xterm's Unicode 11 width provider before output, so wide emoji take two columns instead of one. Fixes #7482
Цей коміт міститься в:
1 джерело
e6c8d6d9ac
коміт
9ecb664036
8 files changed
+48
-6
No files matched your search
@@ -85,6 +85,7 @@
|
||||
"@tauri-apps/plugin-opener": "^2",
|
||||
"@xterm/addon-fit": "0.12.0-beta.334",
|
||||
"@xterm/addon-search": "0.17.0-beta.332",
|
||||
"@xterm/addon-unicode11": "0.10.0-beta.332",
|
||||
"@xterm/xterm": "6.1.0-beta.338",
|
||||
"anser": "^2.3.5",
|
||||
"clsx": "^2.1.1",
|
||||
|
||||
Створено
+12
@@ -128,6 +128,9 @@ importers:
|
||||
'@xterm/addon-search':
|
||||
specifier: 0.17.0-beta.332
|
||||
version: 0.17.0-beta.332(@xterm/[email protected])
|
||||
'@xterm/addon-unicode11':
|
||||
specifier: 0.10.0-beta.332
|
||||
version: 0.10.0-beta.332(@xterm/[email protected])
|
||||
'@xterm/xterm':
|
||||
specifier: 6.1.0-beta.338
|
||||
version: 6.1.0-beta.338
|
||||
@@ -1564,6 +1567,11 @@ packages:
|
||||
peerDependencies:
|
||||
'@xterm/xterm': ^6.1.0-beta.338
|
||||
|
||||
'@xterm/[email protected]':
|
||||
resolution: {integrity: sha512-74+j6gsPld1czK1Zl8+z9LBLsZUZFcgHXP4VSwd+DAPZYTLQcDFV+DbY854enx/9uKNyxuYwR0ec86XFej6iEA==}
|
||||
peerDependencies:
|
||||
'@xterm/xterm': ^6.1.0-beta.338
|
||||
|
||||
'@xterm/[email protected]':
|
||||
resolution: {integrity: sha512-VBygvapFKV5gsqvVFsk6gYpArn4AXnUtZvt3tfN2LXI284i0mivC6Kus84GMJo0GJPLRFziWcSPVz95nViPuWw==}
|
||||
|
||||
@@ -4132,6 +4140,10 @@ snapshots:
|
||||
dependencies:
|
||||
'@xterm/xterm': 6.1.0-beta.338
|
||||
|
||||
'@xterm/[email protected](@xterm/[email protected])':
|
||||
dependencies:
|
||||
'@xterm/xterm': 6.1.0-beta.338
|
||||
|
||||
'@xterm/[email protected]': {}
|
||||
|
||||
[email protected]([email protected]):
|
||||
|
||||
@@ -16,6 +16,7 @@ const terminal = vi.hoisted(() => ({
|
||||
}));
|
||||
vi.mock("@xterm/xterm", () => ({
|
||||
Terminal: class {
|
||||
unicode = { activeVersion: "6" };
|
||||
cols = 80;
|
||||
rows = 24;
|
||||
options = {};
|
||||
|
||||
@@ -10,7 +10,7 @@ import { installTerminalDrop } from "./drop";
|
||||
import { installDomRowCache } from "./domRowCache";
|
||||
import { installTerminalPaste, pasteIntoTerminal } from "./paste";
|
||||
import { ownTerminalInput } from "./imeInput";
|
||||
import { Terminal, type IDisposable } from "@xterm/xterm";
|
||||
import type { Terminal, IDisposable } from "@xterm/xterm";
|
||||
import { FitAddon } from "@xterm/addon-fit";
|
||||
import "@xterm/xterm/css/xterm.css";
|
||||
import "./xtermInput.css";
|
||||
@@ -28,6 +28,7 @@ import { LINK_HANDLER, fontFor, openExternal, openFileLink } from "./session";
|
||||
import { MIN_CONTRAST_RATIO, readLinkColor, readTerminalTheme, remeasureWhenFontsLoad } from "./theme";
|
||||
import { installLinkHighlights, xtermLink, type LinkHighlightController } from "./linkHighlights";
|
||||
import { installModifierPathLinks, type ModifierPathLinksController } from "./pathLinks";
|
||||
import { createXterm } from "./xterm";
|
||||
|
||||
const live = new Map<Terminal, { links: LinkHighlightController; paths: ModifierPathLinksController }>();
|
||||
|
||||
@@ -44,7 +45,7 @@ export function applyThemeToEmbedded() {
|
||||
export function createEmbeddedTerminal(host: HTMLElement, opts: EmbeddedTerminalOptions): EmbeddedTerminal {
|
||||
const settings = workflowSettings().terminal;
|
||||
const font = fontFor(settings);
|
||||
const term = new Terminal({
|
||||
const term = createXterm({
|
||||
...windowsPtyOptions(),
|
||||
linkHandler: LINK_HANDLER,
|
||||
fontFamily: font.family,
|
||||
@@ -56,7 +57,6 @@ export function createEmbeddedTerminal(host: HTMLElement, opts: EmbeddedTerminal
|
||||
cursorBlink: settings.cursorBlink,
|
||||
cursorWidth: 2,
|
||||
cursorInactiveStyle: "outline",
|
||||
allowProposedApi: true,
|
||||
scrollback: 10_000,
|
||||
macOptionIsMeta: settings.optionAsMeta,
|
||||
macOptionClickForcesSelection: true,
|
||||
|
||||
@@ -5,6 +5,7 @@ import { FIT_SETTLE_MS, PROCESS_RESIZE_DELAY_MS } from "./fit";
|
||||
const layout = vi.hoisted(() => ({ cols: 80, rows: 24, resize: () => {} }));
|
||||
vi.mock("@xterm/xterm", () => ({
|
||||
Terminal: class {
|
||||
unicode = { activeVersion: "6" };
|
||||
cols = 80;
|
||||
rows = 24;
|
||||
resized = (_size: { cols: number; rows: number }) => {};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
import { writeClipboardText } from "@/platform/clipboard";
|
||||
import { noteCopySource } from "@/platform/clipboardSource";
|
||||
import { Terminal, type IDisposable, type ILink, type ILinkHandler, type IMarker } from "@xterm/xterm";
|
||||
import type { Terminal, IDisposable, ILink, ILinkHandler, IMarker } from "@xterm/xterm";
|
||||
import { FitAddon } from "@xterm/addon-fit";
|
||||
import { SearchAddon, type ISearchOptions } from "@xterm/addon-search";
|
||||
import screenCss from "./sessionScreen.css?inline";
|
||||
@@ -61,6 +61,7 @@ import {
|
||||
MIN_CONTRAST_RATIO,
|
||||
} from "./theme";
|
||||
import { wheelZoomStep } from "@/platform/wheelZoom";
|
||||
import { createXterm } from "./xterm";
|
||||
|
||||
export const ACTIVE_SEARCH_DECORATION_CLASS = "xterm-find-active-result-decoration";
|
||||
|
||||
@@ -364,7 +365,7 @@ export class TerminalSession {
|
||||
|
||||
const settings = workflowSettings().terminal;
|
||||
const font = fontFor(settings);
|
||||
this.term = new Terminal({
|
||||
this.term = createXterm({
|
||||
...windowsPtyOptions(),
|
||||
fontFamily: font.family,
|
||||
fontSize: font.size,
|
||||
@@ -376,7 +377,6 @@ export class TerminalSession {
|
||||
cursorStyle: CURSOR[settings.cursorShape],
|
||||
cursorWidth: 2,
|
||||
cursorInactiveStyle: "outline",
|
||||
allowProposedApi: true,
|
||||
scrollback: 10_000,
|
||||
macOptionIsMeta: settings.optionAsMeta,
|
||||
macOptionClickForcesSelection: true,
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { createXterm } from "./xterm";
|
||||
|
||||
it("keeps the cursor, emoji and following text in the expected cells", async () => {
|
||||
const term = createXterm({});
|
||||
try {
|
||||
await new Promise<void>((resolve) => term.write("abc\u{1f424} |", resolve));
|
||||
const buffer = term.buffer.active;
|
||||
const line = buffer.getLine(buffer.cursorY)!;
|
||||
expect(line.getCell(3)?.getWidth()).toBe(2);
|
||||
expect(line.getCell(4)?.getWidth()).toBe(0);
|
||||
expect(line.getCell(5)?.getChars()).toBe(" ");
|
||||
expect(line.getCell(6)?.getChars()).toBe("|");
|
||||
expect(buffer.cursorX).toBe(7);
|
||||
} finally {
|
||||
term.dispose();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Unicode11Addon } from "@xterm/addon-unicode11";
|
||||
import { Terminal, type ITerminalInitOnlyOptions, type ITerminalOptions } from "@xterm/xterm";
|
||||
|
||||
export function createXterm(options: ITerminalOptions & ITerminalInitOnlyOptions): Terminal {
|
||||
const term = new Terminal({ ...options, allowProposedApi: true });
|
||||
term.loadAddon(new Unicode11Addon());
|
||||
term.unicode.activeVersion = "11";
|
||||
return term;
|
||||
}
|
||||
Reference in new issue
Заблокувати користувача