fix(tui): remove native modifier escape hatch
This commit is contained in:
@@ -49,7 +49,6 @@ function loadNativeModifiersHelper(): NativeModifiersHelper | undefined {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isNativeModifierPressed(key: ModifierKey): boolean {
|
export function isNativeModifierPressed(key: ModifierKey): boolean {
|
||||||
if (process.env.PI_TUI_DISABLE_NATIVE_MODIFIERS === "1") return false;
|
|
||||||
const helper = loadNativeModifiersHelper();
|
const helper = loadNativeModifiersHelper();
|
||||||
if (!helper) return false;
|
if (!helper) return false;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,20 +1,7 @@
|
|||||||
import assert from "node:assert";
|
import assert from "node:assert";
|
||||||
import { describe, it } from "node:test";
|
import { describe, it } from "node:test";
|
||||||
import { isNativeModifierPressed } from "../src/native-modifiers.ts";
|
|
||||||
import { normalizeAppleTerminalInput, ProcessTerminal } from "../src/terminal.ts";
|
import { normalizeAppleTerminalInput, ProcessTerminal } from "../src/terminal.ts";
|
||||||
|
|
||||||
function withEnv(name: string, value: string | undefined, fn: () => void): void {
|
|
||||||
const previous = process.env[name];
|
|
||||||
if (value === undefined) delete process.env[name];
|
|
||||||
else process.env[name] = value;
|
|
||||||
try {
|
|
||||||
fn();
|
|
||||||
} finally {
|
|
||||||
if (previous === undefined) delete process.env[name];
|
|
||||||
else process.env[name] = previous;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("normalizeAppleTerminalInput", () => {
|
describe("normalizeAppleTerminalInput", () => {
|
||||||
it("rewrites Apple Terminal Return to CSI-u Shift+Enter when Shift is pressed", () => {
|
it("rewrites Apple Terminal Return to CSI-u Shift+Enter when Shift is pressed", () => {
|
||||||
assert.equal(normalizeAppleTerminalInput("\r", true, true), "\x1b[13;2u");
|
assert.equal(normalizeAppleTerminalInput("\r", true, true), "\x1b[13;2u");
|
||||||
@@ -32,13 +19,6 @@ describe("normalizeAppleTerminalInput", () => {
|
|||||||
assert.equal(normalizeAppleTerminalInput("\x1b[13;2u", true, true), "\x1b[13;2u");
|
assert.equal(normalizeAppleTerminalInput("\x1b[13;2u", true, true), "\x1b[13;2u");
|
||||||
assert.equal(normalizeAppleTerminalInput("a", true, true), "a");
|
assert.equal(normalizeAppleTerminalInput("a", true, true), "a");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("treats native helper failure as Shift not pressed", () => {
|
|
||||||
withEnv("PI_TUI_DISABLE_NATIVE_MODIFIERS", "1", () => {
|
|
||||||
assert.equal(isNativeModifierPressed("shift"), false);
|
|
||||||
assert.equal(normalizeAppleTerminalInput("\r", true, isNativeModifierPressed("shift")), "\r");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("ProcessTerminal dimensions", () => {
|
describe("ProcessTerminal dimensions", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user