Fix for Mac double-pasting

This commit is contained in:
Andy Dixon
2026-04-23 11:39:47 +01:00
parent 382f3ca8af
commit 9577b829a0
5 changed files with 28 additions and 0 deletions
+9
View File
@@ -349,6 +349,14 @@
},
),
);
body.appendChild(
this._settingField(
"toggle",
"useNativePaste",
"Use native paste",
p.useNativePaste === true,
),
);
}
/**
@@ -1022,6 +1030,7 @@
"defaultFontSize",
"defaultScrollback",
"defaultCursorStyle",
"useNativePaste",
];
for (const field of fields) {
+15
View File
@@ -84,6 +84,14 @@
const attachPasteGuard = () => {
const inputEl = term.textarea || container.querySelector("textarea");
if (!inputEl) return;
inputEl.addEventListener("keydown", (e) => {
const mod = e.ctrlKey || e.metaKey;
if (!mod || e.key !== "v") return;
// Block the native paste when we handle Cmd/Ctrl+V ourselves.
if (!suppressPasteEvent) return;
e.preventDefault();
e.stopPropagation();
});
inputEl.addEventListener("paste", (e) => {
if (!suppressPasteEvent) return;
e.preventDefault();
@@ -182,7 +190,14 @@
// Cmd/Ctrl+V — paste from clipboard
if (mod && e.key === "v" && e.type === "keydown") {
const prefs = this.app.state.preferences || {};
if (prefs.useNativePaste === true) {
suppressPasteEvent = false;
return true;
}
suppressPasteEvent = true;
e.preventDefault();
e.stopPropagation();
setTimeout(() => {
suppressPasteEvent = false;
}, 250);
+2
View File
@@ -12,6 +12,7 @@ export namespace models {
defaultFontSize: number;
defaultScrollback: number;
defaultCursorStyle: string;
useNativePaste: boolean;
static createFrom(source: any = {}) {
return new AppPreferences(source);
@@ -30,6 +31,7 @@ export namespace models {
this.defaultFontSize = source["defaultFontSize"];
this.defaultScrollback = source["defaultScrollback"];
this.defaultCursorStyle = source["defaultCursorStyle"];
this.useNativePaste = source["useNativePaste"];
}
}
export class AuditEntry {
+1
View File
@@ -49,6 +49,7 @@ func DefaultAppPreferences() AppPreferences {
DefaultFontSize: DefaultFontSize,
DefaultScrollback: DefaultScrollback,
DefaultCursorStyle: DefaultCursorStyle,
UseNativePaste: false,
}
}
+1
View File
@@ -263,6 +263,7 @@ type AppPreferences struct {
DefaultFontSize int `json:"defaultFontSize"`
DefaultScrollback int `json:"defaultScrollback"`
DefaultCursorStyle string `json:"defaultCursorStyle"`
UseNativePaste bool `json:"useNativePaste"`
}
// AuditEntry records an auditable action within the application.