fix(tui): avoid duplicate VS Code right-click paste

closes #8186
This commit is contained in:
Armin Ronacher 2026-08-17 11:40:05 +02:00
parent 955a543b31
commit 374e56e553
4 changed files with 22 additions and 2 deletions

View file

@ -7,6 +7,7 @@
- Fixed `pi.registerFlag()` accepting default values that do not match the declared flag type ([#8064](https://github.com/earendil-works/pi/issues/8064)).
- Fixed Z.AI Coding Plan defaults referencing the removed GLM-5.1 model ([#8096](https://github.com/earendil-works/pi/issues/8096)).
- Fixed repeated ambiguous truncated-response recovery being mislabeled as context overflow ([#8130](https://github.com/earendil-works/pi/issues/8130)).
- Fixed duplicate fullscreen right-click paste in VS Code-based terminals on Windows ([#8186](https://github.com/earendil-works/pi/issues/8186)).
## [0.84.2] - 2026-08-14

View file

@ -2,6 +2,10 @@
## [Unreleased]
### Fixed
- Fixed duplicate fullscreen right-click paste in VS Code-based terminals on Windows ([#8186](https://github.com/earendil-works/pi/issues/8186)).
## [0.84.2] - 2026-08-14
### Added

View file

@ -695,7 +695,13 @@ export class TuiAltScreen extends TuiBase implements ViewportTUI {
}
private handleRightClickPaste(event: SgrMouseEvent): boolean {
if (!this.onRightClickPaste || process.platform !== "win32" || event.release || event.button !== 2) {
if (
!this.onRightClickPaste ||
process.platform !== "win32" ||
process.env.TERM_PROGRAM?.toLowerCase() === "vscode" ||
event.release ||
event.button !== 2
) {
return false;
}
try {

View file

@ -225,8 +225,9 @@ describe("TuiAltScreen", () => {
}
});
it("invokes the right-click paste handler only on Windows", () => {
it("invokes the right-click paste handler only on Windows outside VS Code", () => {
const platformDescriptor = Object.getOwnPropertyDescriptor(process, "platform");
const termProgram = process.env.TERM_PROGRAM;
assert.ok(platformDescriptor);
const terminal = new VirtualTerminal();
let pasteCount = 0;
@ -237,17 +238,25 @@ describe("TuiAltScreen", () => {
});
try {
Object.defineProperty(process, "platform", { configurable: true, value: "win32" });
delete process.env.TERM_PROGRAM;
tui.start();
terminal.sendInput("\x1b[<2;1;1M");
terminal.sendInput("\x1b[<2;1;1m");
assert.strictEqual(pasteCount, 1);
process.env.TERM_PROGRAM = "vscode";
terminal.sendInput("\x1b[<2;1;1M");
assert.strictEqual(pasteCount, 1);
Object.defineProperty(process, "platform", { configurable: true, value: "linux" });
delete process.env.TERM_PROGRAM;
terminal.sendInput("\x1b[<2;1;1M");
assert.strictEqual(pasteCount, 1);
} finally {
tui.stop();
Object.defineProperty(process, "platform", platformDescriptor);
if (termProgram === undefined) delete process.env.TERM_PROGRAM;
else process.env.TERM_PROGRAM = termProgram;
}
});