You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The History view reads from the start of the PSReadLine history instead of the end. This causes it to only ever show the first 25 lines going by the command run in the log. This would be super-easy to fix if -First was changed to -Last. It might also be nice to have a setting to show more than 25 items, e.g. "poshProTools.historyMaxItems": 100 or something thereabouts. Lastly, lines ending with a continuation backtick are attempted to be combined rather than left as-is. This wouldn't be a huge deal except that they aren't combined properly, leaving out most of any command ending in a line continuation backtick. See attached screenshot for an example of this.
Log output on refresh
[19:33:55.337] Scheduling command for main runspace: Get-Content (Get-PSReadLineOption).HistorySavePath |Select-Object-First 25
Expected Behavior
By order of importance (in my opinion), the view should:
Read from the end of the file, whether it sorts descending or ascending in the view afterwards.
Correctly concatenate lines that end with a backtick
Ideally, read more than 25 lines, perhaps with a related setting, or just by using the pre-existing ⚙️terminal.integrated.shellIntegration.history.
Trim extension host injection commands from the history, e.g. Import-Module, Start-PoshToolsServer, and Clear-Host. I'm sure there's a way to leave these out of the history to start with, as you wind up with a lot after some time, a minimum of six-eight lines per launch, more if the extension needs to restart.
See below for ideas on how to fix these. If I learn enough about Github and VSCode extensions I might attempt a PR myself?
Actual Behavior
The view reads from the beginning of the PSReadLine history, showing the first 25 items and remaining static forever, unless the PSReadLine history save path is changed. See attached screenshot for this.
Not a huge deal, but given the extension requires that persistent terminal sessions be disabled, it's not a good replacement. Reading from the end of the history, fixing line concatenation, and expanding the history size from a meager 25 items are the three issues I've found here.
Issue 1
All that needs to happen to fix this is to change the Select-Object parameter from -First to -Last.
Issue 2
This issue lies in the method that does this in PoshToolsServer.cs - GetHistory(). In my short skimming of the code, I think there needs to be a third condition, as I think what's happening is that each time a line of text is detected as ending with a backtick, the StringBuilder object is re-instantiated before appending the line without regard to whether it's still in the middle of a multi-line statement. Then on the loop after the last line detected (multiLine != null), only a single line is added to the result list from the multiLine variable, usually leaving the last line and perhaps a closing bracket in the history view where a full multi-line statement ought to be (see screenshot). Excusing my crappy C#, adding a check for multiLine being null or not along with a fourth condition in the foreach loop might solve this, i.e.:
// the first line ending in `if(item.EndsWith('`')&&multiLine==null){multiLine=new StringBuilder();
multiLine.AppendLine(item.TrimEnd('`'));}// subsequent lines ending in `elseif(item.EndsWith('`')&&multiLine!=null){
multiLine.AppendLine(item.TrimEnd('`'));}// the next line afterelseif(multiLine!=null){// continued as usual...}
Issue 3
I think this could easily be added by just using the ⚙️terminal.integrated.shellIntegration.history setting for the number of lines, whether in the Select-Object call, or by reading in the entire history, and limiting in the JS extension code that refreshes the History view.
Issue 4
Adding the following regex exclusion (whether by adding Select-String <pattern> -NotMatch to the get history call, or in the C# code while processing the lines) would prune any startup injection commands from the history:
Verify the History view is enabled: setting ⚙️poshProTools.sideBar.historyVisibility is set to True.
Run any command in the Terminal, and observe that the History view contains the same 25 lines.
Compare the items in History to your PSReadLine history file (should be in $env:appdata\Microsoft\Windows\PowerShell\PSReadLine\Visual Studio Code Host_history.txt -- run code (Get-PSReadLineOption).HistorySavePath to open it). The first 25 items should be the same, albeit missing lines ending in backticks, and with their order reversed in the view due to result.Reverse(); in the associated code.
Screenshots
As can be seen, the first 25 lines are shown. And, only the last line ending in a backtick for the multi-line statement was added.
The text was updated successfully, but these errors were encountered:
Describe the bug
The History view reads from the start of the PSReadLine history instead of the end. This causes it to only ever show the first 25 lines going by the command run in the log. This would be super-easy to fix if
-First
was changed to-Last
. It might also be nice to have a setting to show more than 25 items, e.g."poshProTools.historyMaxItems": 100
or something thereabouts. Lastly, lines ending with a continuation backtick are attempted to be combined rather than left as-is. This wouldn't be a huge deal except that they aren't combined properly, leaving out most of any command ending in a line continuation backtick. See attached screenshot for an example of this.Log output on refresh
Expected Behavior
By order of importance (in my opinion), the view should:
⚙️terminal.integrated.shellIntegration.history
.Import-Module
,Start-PoshToolsServer
, andClear-Host
. I'm sure there's a way to leave these out of the history to start with, as you wind up with a lot after some time, a minimum of six-eight lines per launch, more if the extension needs to restart.See below for ideas on how to fix these. If I learn enough about Github and VSCode extensions I might attempt a PR myself?
Actual Behavior
The view reads from the beginning of the PSReadLine history, showing the first 25 items and remaining static forever, unless the PSReadLine history save path is changed. See attached screenshot for this.
Not a huge deal, but given the extension requires that persistent terminal sessions be disabled, it's not a good replacement. Reading from the end of the history, fixing line concatenation, and expanding the history size from a meager 25 items are the three issues I've found here.
Issue 1
All that needs to happen to fix this is to change the
Select-Object
parameter from-First
to-Last
.Issue 2
This issue lies in the method that does this in PoshToolsServer.cs - GetHistory(). In my short skimming of the code, I think there needs to be a third condition, as I think what's happening is that each time a line of text is detected as ending with a backtick, the StringBuilder object is re-instantiated before appending the line without regard to whether it's still in the middle of a multi-line statement. Then on the loop after the last line detected (
multiLine != null
), only a single line is added to the result list from the multiLine variable, usually leaving the last line and perhaps a closing bracket in the history view where a full multi-line statement ought to be (see screenshot). Excusing my crappy C#, adding a check for multiLine being null or not along with a fourth condition in the foreach loop might solve this, i.e.:Issue 3
I think this could easily be added by just using the
⚙️terminal.integrated.shellIntegration.history
setting for the number of lines, whether in theSelect-Object
call, or by reading in the entire history, and limiting in the JS extension code that refreshes the History view.Issue 4
Adding the following regex exclusion (whether by adding
Select-String <pattern> -NotMatch
to the get history call, or in the C# code while processing the lines) would prune any startup injection commands from the history:Version
Steps to Reproduce
⚙️poshProTools.sideBar.historyVisibility
is set to True.$env:appdata\Microsoft\Windows\PowerShell\PSReadLine\Visual Studio Code Host_history.txt
-- runcode (Get-PSReadLineOption).HistorySavePath
to open it). The first 25 items should be the same, albeit missing lines ending in backticks, and with their order reversed in the view due toresult.Reverse();
in the associated code.Screenshots
As can be seen, the first 25 lines are shown. And, only the last line ending in a backtick for the multi-line statement was added.
The text was updated successfully, but these errors were encountered: