From bedadc3135d95dd962d36e6ea2ddd56ddc54e0fe Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Tue, 17 Jun 2025 14:19:22 -0700 Subject: [PATCH] Import shell integration module --- .../Services/PowerShell/Host/PsesInternalHost.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs b/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs index a2072b2d9..517c4825d 100644 --- a/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs +++ b/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs @@ -317,6 +317,7 @@ public async Task TryStartAsync(HostStartOptions startOptions, Cancellatio { _logger.LogDebug("Enabling Terminal Shell Integration..."); _shellIntegrationEnabled = true; + string sourceMethod = startOptions.ShellIntegrationScript.EndsWith(".ps1") ? "." : "Import-Module"; // TODO: Make the __psEditorServices prefix shared (it's used elsewhere too). string setupShellIntegration = $$""" # Setup Terminal Shell Integration. @@ -327,7 +328,7 @@ public async Task TryStartAsync(HostStartOptions startOptions, Cancellatio function global:PSConsoleHostReadLine { $global:__psEditorServices_userInput } # Execute the provided shell integration script. - try { . '{{startOptions.ShellIntegrationScript}}' } catch {} + try { {{sourceMethod}} '{{startOptions.ShellIntegrationScript}}' } catch {} """; await EnableShellIntegrationAsync(setupShellIntegration, cancellationToken).ConfigureAwait(false); _logger.LogDebug("Shell integration enabled!");