From c82bbcc7274d779ffe62a8c7048c25d88dbff8c7 Mon Sep 17 00:00:00 2001 From: xinyi-gong Date: Wed, 29 Jul 2026 14:19:39 +0800 Subject: [PATCH] prevent terminal hangs when PowerShell prompt fails --- .../scripts/copilot-powershell-integration.ps1 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/com.microsoft.copilot.eclipse.terminal.api/scripts/copilot-powershell-integration.ps1 b/com.microsoft.copilot.eclipse.terminal.api/scripts/copilot-powershell-integration.ps1 index 5cc0c77e7..23664fdd7 100644 --- a/com.microsoft.copilot.eclipse.terminal.api/scripts/copilot-powershell-integration.ps1 +++ b/com.microsoft.copilot.eclipse.terminal.api/scripts/copilot-powershell-integration.ps1 @@ -39,12 +39,19 @@ if (-not $global:COPILOT_SHELL_INTEGRATION) { $result += "$esc]7775;A$bel" + $promptText = $null if ($global:__copilot_original_prompt) { - $result += $global:__copilot_original_prompt.Invoke() - } else { - $result += "PS $($executionContext.SessionState.Path.CurrentLocation)> " + try { + $promptText = & $global:__copilot_original_prompt 2>$null + } catch { + $promptText = $null + } } + if ($null -eq $promptText -or "$promptText" -eq "") { + $promptText = "PS $($executionContext.SessionState.Path.CurrentLocation)> " + } + $result += $promptText $result += "$esc]7775;B$bel" if ($null -ne $lastHistoryEntry) { $global:__copilot_last_history_id = $lastHistoryEntry.Id