Skip to content

Commit 9c07157

Browse files
committed
fix: terminal doesnt work in windows and ctrl/cmd c to copy sleected text in terminal
1 parent a40d171 commit 9c07157

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

src/extensionsIntegrated/Terminal/TerminalInstance.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ define(function (require, exports, module) {
236236
};
237237

238238
/**
239-
* Custom key event handler - intercept editor shortcuts
239+
* Custom key event handler - intercept editor shortcuts and clipboard keys
240240
* Returns true to allow xterm to handle, false to prevent
241241
*/
242242
TerminalInstance.prototype._customKeyHandler = function (event) {
@@ -247,6 +247,11 @@ define(function (require, exports, module) {
247247

248248
const ctrlOrMeta = event.ctrlKey || event.metaKey;
249249

250+
// Ctrl+C with a selection should copy to clipboard, not send SIGINT
251+
if (ctrlOrMeta && !event.shiftKey && event.key.toLowerCase() === "c" && this.terminal.hasSelection()) {
252+
return false;
253+
}
254+
250255
for (const shortcut of EDITOR_SHORTCUTS) {
251256
const ctrlMatch = shortcut.ctrlKey ? ctrlOrMeta : !ctrlOrMeta;
252257
const shiftMatch = shortcut.shiftKey ? event.shiftKey : !event.shiftKey;

src/extensionsIntegrated/Terminal/main.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,19 @@ define(function (require, exports, module) {
200200
return;
201201
}
202202

203-
// Get project root as cwd, stripping VFS prefix for native path
203+
// Get project root as cwd, converting VFS path to native platform path
204204
const projectRoot = ProjectManager.getProjectRoot();
205205
let cwd;
206206
if (projectRoot) {
207-
cwd = projectRoot.fullPath;
208-
// Strip Phoenix VFS prefix (/tauri/) to get native filesystem path
207+
const fullPath = projectRoot.fullPath;
209208
const tauriPrefix = Phoenix.VFS.getTauriDir();
210-
if (cwd.startsWith(tauriPrefix)) {
211-
cwd = "/" + cwd.slice(tauriPrefix.length);
209+
if (fullPath.startsWith(tauriPrefix)) {
210+
cwd = Phoenix.fs.getTauriPlatformPath(fullPath);
211+
} else {
212+
cwd = fullPath;
212213
}
213-
// Remove trailing slash (posix_spawnp can fail with trailing slashes)
214-
if (cwd.length > 1 && cwd.endsWith("/")) {
214+
// Remove trailing slash/backslash (posix_spawnp can fail with trailing slashes)
215+
if (cwd.length > 1 && (cwd.endsWith("/") || cwd.endsWith("\\"))) {
215216
cwd = cwd.slice(0, -1);
216217
}
217218
}

0 commit comments

Comments
 (0)