From f3737cd91d092a6dca238d44d8ec25aaf6e043af Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Wed, 25 May 2022 05:59:12 +0200 Subject: [PATCH] fix(pwsh): move functions before module declaration relates to #2318 --- src/shell/scripts/omp.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/shell/scripts/omp.ps1 b/src/shell/scripts/omp.ps1 index a97972f0..809b1b3e 100644 --- a/src/shell/scripts/omp.ps1 +++ b/src/shell/scripts/omp.ps1 @@ -3,6 +3,8 @@ if ($null -ne (Get-Module -Name "oh-my-posh-core")) { Remove-Module -Name "oh-my-posh-core" -Force } +# Helper functions which need to be defined before the module is loaded +# See https://github.com/JanDeDobbeleer/oh-my-posh/discussions/2300 function Get-PoshStackCount { $locations = Get-Location -Stack if ($locations) { @@ -11,6 +13,9 @@ function Get-PoshStackCount { return 0 } +# See https://github.com/JanDeDobbeleer/oh-my-posh/discussions/1928 +function Test-PSDebugContext { return Test-Path Variable:/PSDebugContext } + New-Module -Name "oh-my-posh-core" -ScriptBlock { $script:ErrorCode = 0 $script:OMPExecutable = '::OMP::' @@ -312,5 +317,3 @@ Example: "prompt" ) } | Import-Module -Global - -function Test-PSDebugContext { return Test-Path Variable:/PSDebugContext }