diff --git a/Module/Public/Add-PSFavorite.ps1 b/Module/Public/Add-PSFavorite.ps1
index a7875e5..f9108c3 100644
--- a/Module/Public/Add-PSFavorite.ps1
+++ b/Module/Public/Add-PSFavorite.ps1
@@ -24,4 +24,5 @@ function Add-PSFavorite(
[string] $FavoritesPath = $Script:FavoritesPath
) {
$Command | Out-File -FilePath $FavoritesPath -Append
+ [PSFavorite.PSFavoritePredictor]::Reload()
}
diff --git a/Module/Public/Optimize-PSFavorites.ps1 b/Module/Public/Optimize-PSFavorites.ps1
index fbb71a2..05575fc 100644
--- a/Module/Public/Optimize-PSFavorites.ps1
+++ b/Module/Public/Optimize-PSFavorites.ps1
@@ -23,5 +23,6 @@ function Optimize-PSFavorites(
end {
$Favorites | Out-File -FilePath $FavoritesPath
+ [PSFavorite.PSFavoritePredictor]::Reload()
}
}
diff --git a/Module/Public/Remove-PSFavorite.ps1 b/Module/Public/Remove-PSFavorite.ps1
index 2ae445b..842d431 100644
--- a/Module/Public/Remove-PSFavorite.ps1
+++ b/Module/Public/Remove-PSFavorite.ps1
@@ -49,6 +49,7 @@ function Remove-PSFavorite {
if ($PSCmdlet.ShouldProcess("Save changes to the favorites list?")) {
$Favorites | Out-File -FilePath $FavoritesPath
Write-Verbose "Changes saved to the favorites list."
+ [PSFavorite.PSFavoritePredictor]::Reload()
}
}
diff --git a/Predictor/PSFavoritePredictor.cs b/Predictor/PSFavoritePredictor.cs
index d3c87be..f8ea691 100644
--- a/Predictor/PSFavoritePredictor.cs
+++ b/Predictor/PSFavoritePredictor.cs
@@ -84,6 +84,15 @@ public static void Initialize(string favoritesPath)
LoadFavoritesIfExists();
}
+ ///
+ /// Reload the favorites from the file. Call this after modifying the favorites file
+ /// to immediately reflect changes in the predictor.
+ ///
+ public static void Reload()
+ {
+ LoadFavoritesIfExists();
+ }
+
///
/// Load the favorites from the file if it exists. If any error occurs, set favorites to an empty array.
///