Skip to content

Commit 3a429ea

Browse files
Import shell integration module (#2233)
1 parent 1a988a9 commit 3a429ea

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ public async Task<bool> TryStartAsync(HostStartOptions startOptions, Cancellatio
317317
{
318318
_logger.LogDebug("Enabling Terminal Shell Integration...");
319319
_shellIntegrationEnabled = true;
320+
string sourceMethod = startOptions.ShellIntegrationScript.EndsWith(".ps1") ? "." : "Import-Module";
320321
// TODO: Make the __psEditorServices prefix shared (it's used elsewhere too).
321322
string setupShellIntegration = $$"""
322323
# Setup Terminal Shell Integration.
@@ -327,7 +328,7 @@ public async Task<bool> TryStartAsync(HostStartOptions startOptions, Cancellatio
327328
function global:PSConsoleHostReadLine { $global:__psEditorServices_userInput }
328329
329330
# Execute the provided shell integration script.
330-
try { . '{{startOptions.ShellIntegrationScript}}' } catch {}
331+
try { {{sourceMethod}} '{{startOptions.ShellIntegrationScript}}' } catch {}
331332
""";
332333
await EnableShellIntegrationAsync(setupShellIntegration, cancellationToken).ConfigureAwait(false);
333334
_logger.LogDebug("Shell integration enabled!");

0 commit comments

Comments
 (0)