Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix History View #107

Merged
merged 5 commits into from
Jan 3, 2025
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
7 changes: 0 additions & 7 deletions .github/workflows/vscode.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ jobs:
dotnet restore PowerShellTools.sln
nuget restore PowerShellTools.sln

- name: Build Ironman Host
shell: pwsh
run: |
Push-Location IronmanPowerShellHost
dotnet publish -f net472 -c Release .\IronmanPowerShellHost.csproj
Pop-Location

- name: Build Windows Form Designer
shell: pwsh
run: |
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/vscode.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,7 @@ jobs:
dotnet restore PowerShellTools.sln
nuget restore PowerShellTools.sln

- name: Build Ironman Host
shell: pwsh
run: |
Push-Location IronmanPowerShellHost
dotnet publish -f net472 -c Release .\IronmanPowerShellHost.csproj
Pop-Location

- name: Build PSScriptPad
- name: Build Windows Form Designer
shell: pwsh
run: |
msbuild PowerShellTools.sln -t:rebuild -p:Configuration=Release -p:Platform=x64
Expand Down
22 changes: 17 additions & 5 deletions HostInjection/PoshToolsServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -812,24 +812,36 @@ public void RefreshTreeView(string treeViewId)
ExecutePowerShell($"[PowerShellToolsPro.VSCode.TreeViewService]::Instance.RefreshTreeView('{treeViewId}')");
}

public IEnumerable<string> GetHistory()
public IEnumerable<string> GetHistory(int count)
{
var history = ExecutePowerShellMainRunspace<string>("Get-Content (Get-PSReadLineOption).HistorySavePath | Select-Object -First 25");
var history = ExecutePowerShellMainRunspace<string>("Get-Content (Get-PSReadLineOption).HistorySavePath");
var result = new List<string>();

var regEx = new System.Text.RegularExpressions.Regex(@"Get-Content \(Get-PSReadLineOption\).HistorySavePath|Clear-Host|Import-Module '.*PowerShellProTools(?:\.VSCode)?\.psd1'|Start-PoshToolsServer -PipeName '\w+'(?:\nClear-Host)?");

StringBuilder multiLine = null;
foreach (var item in history)
{
if (item.EndsWith("`"))
// Skip the import and start server commands
if (regEx.Match(item).Success)
{
continue;
}

if (item.EndsWith("`") && multiLine == null)
{
multiLine = new StringBuilder();
multiLine.AppendLine(item.TrimEnd('`'));
}
else if (item.EndsWith("`") && multiLine != null)
{
multiLine.AppendLine(item.TrimEnd('`'));
}
else if (multiLine != null)
{
multiLine.AppendLine(item.TrimEnd('`'));
result.Add(multiLine.ToString());
multiLine = null;
result.Add(item);
}
else
{
Expand All @@ -839,7 +851,7 @@ public IEnumerable<string> GetHistory()

result.Reverse();

return result;
return result.Take(count);
}

public IEnumerable<PSJob> GetJobs()
Expand Down
4 changes: 4 additions & 0 deletions HostInjection/PowerShellProTools.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@

<ItemGroup>
<None Remove="PowerShellProTools.VSCode.psd1" />
<None Remove="PowerShellProTools.VSCode.psm1" />
</ItemGroup>

<ItemGroup>
<Content Include="PowerShellProTools.VSCode.psd1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="PowerShellProTools.VSCode.psm1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
Expand Down
146 changes: 15 additions & 131 deletions HostInjection/PowerShellProTools.VSCode.psd1
Original file line number Diff line number Diff line change
@@ -1,132 +1,16 @@
#
# Module manifest for module 'PowerShellProTools.VSCode'
#
# Generated by: adamr
#
# Generated on: 18/06/2020
#

@{

# Script module or binary module file associated with this manifest.
RootModule = 'PowerShellProTools.VSCode.dll'

# Version number of this module.
ModuleVersion = '0.0.1'

# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = '6445e5c3-d794-4af8-82a4-7ee94e0d4f1b'

# Author of this module
Author = 'adamr'

# Company or vendor of this module
CompanyName = 'Unknown'

# Copyright statement for this module
Copyright = '(c) adamr. All rights reserved.'

# Description of the functionality provided by this module
# Description = ''

# Minimum version of the PowerShell engine required by this module
# PowerShellVersion = ''

# Name of the PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# ClrVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = @('PowerShellProTools.VSCode.dll')

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = '*'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = '*'

# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = '*'

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()

# A URL to the license for this module.
# LicenseUri = ''

# A URL to the main website for this project.
# ProjectUri = ''

# A URL to an icon representing this module.
# IconUri = ''

# ReleaseNotes of this module
# ReleaseNotes = ''

# Prerelease string of this module
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false

# External dependent modules of this module
# ExternalModuleDependencies = @()

} # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}

RootModule = 'PowerShellProTools.VSCode.psm1'
ModuleVersion = '2024.12.0'
GUID = '6445e5c3-d794-4af8-82a4-7ee94e0d4f1b'
Author = 'Ironman Software'
CompanyName = 'Ironman Software'
Copyright = '(c) Ironman Software. All rights reserved.'
FunctionsToExport = '*'
CmdletsToExport = '*'
VariablesToExport = '*'
AliasesToExport = '*'
PrivateData = @{
PSData = @{
}
}
}
2 changes: 2 additions & 0 deletions HostInjection/PowerShellProTools.VSCode.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Import-Module "$PSScriptRoot\PowerShellProTools.VSCode.dll"
Import-Module "$PSScriptRoot\PowerShellProTools.SharedCommands.dll"
2 changes: 2 additions & 0 deletions PowerShellTools.2022/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,7 @@
"dependencies": {
"Microsoft.Win32.Registry": "[4.5.0, )",
"Newtonsoft.Json": "[9.0.1, )",
"PowerShellProTools.SharedCommands": "[1.0.0, )",
"PowerShellProTools.VSCode": "[1.0.0, )",
"PowerShellStandard.Library": "[5.1.0, )",
"Serilog.Sinks.File": "[5.0.0, )"
Expand All @@ -1822,6 +1823,7 @@
"FormDesigner.Generator": "[1.0.0, )",
"ICSharpCode.Decompiler": "[7.0.0.6488, )",
"Newtonsoft.Json": "[9.0.1, )",
"PowerShellProTools.SharedCommands": "[1.0.0, )",
"PowerShellStandard.Library": "[5.1.0, )"
}
},
Expand Down
2 changes: 2 additions & 0 deletions PowerShellTools.Test/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,7 @@
"dependencies": {
"Microsoft.Win32.Registry": "[4.5.0, )",
"Newtonsoft.Json": "[9.0.1, )",
"PowerShellProTools.SharedCommands": "[1.0.0, )",
"PowerShellProTools.VSCode": "[1.0.0, )",
"PowerShellStandard.Library": "[5.1.0, )",
"Serilog.Sinks.File": "[5.0.0, )"
Expand All @@ -1221,6 +1222,7 @@
"FormDesigner.Generator": "[1.0.0, )",
"ICSharpCode.Decompiler": "[7.0.0.6488, )",
"Newtonsoft.Json": "[9.0.1, )",
"PowerShellProTools.SharedCommands": "[1.0.0, )",
"PowerShellStandard.Library": "[5.1.0, )"
}
},
Expand Down
2 changes: 2 additions & 0 deletions PowerShellTools/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,7 @@
"dependencies": {
"Microsoft.Win32.Registry": "[4.5.0, )",
"Newtonsoft.Json": "[9.0.1, )",
"PowerShellProTools.SharedCommands": "[1.0.0, )",
"PowerShellProTools.VSCode": "[1.0.0, )",
"PowerShellStandard.Library": "[5.1.0, )",
"Serilog.Sinks.File": "[5.0.0, )"
Expand All @@ -1161,6 +1162,7 @@
"FormDesigner.Generator": "[1.0.0, )",
"ICSharpCode.Decompiler": "[7.0.0.6488, )",
"Newtonsoft.Json": "[9.0.1, )",
"PowerShellProTools.SharedCommands": "[1.0.0, )",
"PowerShellStandard.Library": "[5.1.0, )"
}
},
Expand Down
4 changes: 2 additions & 2 deletions PowerShellToolsPro.Cmdlets/PowerShellProTools.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Ironman Software, LLC
#
# Generated on: 1/2/2025
# Generated on: 1/3/2025
#

@{
Expand All @@ -18,7 +18,7 @@ ModuleVersion = '2024.7.0'
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = 'd58b50e7-7308-40ab-88d6-047d257369f9'
GUID = 'b0200020-cc25-4759-9ca7-2b3ad13e4ede'

# Author of this module
Author = 'Ironman Software, LLC'
Expand Down
24 changes: 12 additions & 12 deletions PowerShellToolsPro.Cmdlets/PowerShellProTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ function Expand-Object {
# 8GehghbYMIIW1AYKKwYBBAGCNwMDATGCFsQwghbABgkqhkiG9w0BBwKgghaxMIIW
# rQIBAzENMAsGCWCGSAFlAwQCATCB8wYLKoZIhvcNAQkQAQSggeMEgeAwgd0CAQEG
# CysGAQQBoDICAwECMDEwDQYJYIZIAWUDBAIBBQAEICkx1mva4klxbeW4WP91UJmg
# DWt4BcXyh6cRKmeE4SEcAhQs/iKdfjMFv2gVDntkmCXmRM5WJRgPMjAyNTAxMDIx
# NzMzMTFaMAMCAQECCQCoCG1FPQKbcqBhpF8wXTELMAkGA1UEBhMCQkUxGTAXBgNV
# DWt4BcXyh6cRKmeE4SEcAhQ6MO4iOS+VvygaK6YpjeByW+SNARgPMjAyNTAxMDMx
# NzE3NTFaMAMCAQECCQDsyDBQwh86e6BhpF8wXTELMAkGA1UEBhMCQkUxGTAXBgNV
# BAoMEEdsb2JhbFNpZ24gbnYtc2ExMzAxBgNVBAMMKkdsb2JhbHNpZ24gVFNBIGZv
# ciBDb2RlU2lnbjEgLSBSNiAtIDIwMjMxMaCCElQwggWDMIIDa6ADAgECAg5F5rsD
# gzPDhWVI5v9FUTANBgkqhkiG9w0BAQwFADBMMSAwHgYDVQQLExdHbG9iYWxTaWdu
Expand Down Expand Up @@ -257,17 +257,17 @@ function Expand-Object {
# bWVzdGFtcGluZyBDQSAtIFNIQTM4NCAtIEc0AhABm+reyE1rj/dsOp8uASQWMAsG
# CWCGSAFlAwQCAaCCAS0wGgYJKoZIhvcNAQkDMQ0GCyqGSIb3DQEJEAEEMCsGCSqG
# SIb3DQEJNDEeMBwwCwYJYIZIAWUDBAIBo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2yWcE5L7myRFNt3bETtMrD9Pt7xBOkSCVcvo+OY8+QXOEq911LmORAmz5TAdrZUT
# bIprtK6/EcgKlahEvHFx7S+WiMhCMn1Eir+sPs5o+ymFlKBQawpPO/n1qCjtWvJi
# n2/AthFrVnms/2AUDvdVdqhukb0Oe8sH/lnEsos2KpJYEVDigkvNb6JLK9pblZ5G
# JSQII5WlU/8f+x9qhNfQ34mzbq1Wc5ZY5OZErJAZnFuytVi3WqwGbTizPm6eW7ub
# JshYLT38RIJJDjc3UySFW+f0FLDMfjQjl2SRHsLDDMZUXRf7UlDk9XF4xi/eQ30W
# 4YkKCIduxXqyhCoAKOWhTiGVVk7nNo571CORtPYTSLR0IezQNkG0iIFWwm3VYjyp
# AB4qwPRv5gwjyvUz8+omJ1hzZnda5oeMMJW5Nl27lKmd1iEkrTF8l2k6VyFjJQ==
# SIG # End signature block
Loading
Loading