Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Module/Public/Add-PSFavorite.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ function Add-PSFavorite(
[string] $FavoritesPath = $Script:FavoritesPath
) {
$Command | Out-File -FilePath $FavoritesPath -Append
[PSFavorite.PSFavoritePredictor]::Reload()
}
1 change: 1 addition & 0 deletions Module/Public/Optimize-PSFavorites.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ function Optimize-PSFavorites(

end {
$Favorites | Out-File -FilePath $FavoritesPath
[PSFavorite.PSFavoritePredictor]::Reload()
}
}
1 change: 1 addition & 0 deletions Module/Public/Remove-PSFavorite.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

}
9 changes: 9 additions & 0 deletions Predictor/PSFavoritePredictor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ public static void Initialize(string favoritesPath)
LoadFavoritesIfExists();
}

/// <summary>
/// Reload the favorites from the file. Call this after modifying the favorites file
/// to immediately reflect changes in the predictor.
/// </summary>
public static void Reload()
{
LoadFavoritesIfExists();
}

/// <summary>
/// Load the favorites from the file if it exists. If any error occurs, set favorites to an empty array.
/// </summary>
Expand Down