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!");