From 44818b3f74361b5d0d13cabf9d903a47fd7edf49 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 20 Jun 2026 23:15:00 +0000 Subject: [PATCH 1/2] Initial plan From b4d5e54c5076284c93ab45a23525549d135c0ab9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 20 Jun 2026 23:18:53 +0000 Subject: [PATCH 2/2] Fix reverse history multiline insertion delimiter --- PSFzf.Base.ps1 | 2 +- PSFzf.tests.ps1 | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/PSFzf.Base.ps1 b/PSFzf.Base.ps1 index 07afee8..01ea962 100644 --- a/PSFzf.Base.ps1 +++ b/PSFzf.Base.ps1 @@ -947,7 +947,7 @@ function Invoke-FzfPsReadlineHandlerHistory { $result = Get-PickedHistory -Query $line -UsePSReadLineHistory if ($result -is [system.array]) { - $result = $result -join "```n" + $result = $result -join "`n" } InvokePromptHack diff --git a/PSFzf.tests.ps1 b/PSFzf.tests.ps1 index 37ba231..78d45ad 100644 --- a/PSFzf.tests.ps1 +++ b/PSFzf.tests.ps1 @@ -842,5 +842,56 @@ if ( $false ) { } } } + + } +} + +Describe "Invoke-FzfPsReadlineHandlerHistory multiline insertion" { + InModuleScope PsFzf { + BeforeEach { + Mock Get-PSConsoleReadLineBufferState { + [pscustomobject]@{ + Line = '' + Cursor = 0 + } + } -ModuleName PsFzf + + Mock InvokePromptHack {} -ModuleName PsFzf + Mock Replace-PSConsoleReadLineText {} -ModuleName PsFzf + } + + It "Should join multiline history selections with newlines only" { + $historySelection = @( + '$a = 1' + '$b = 2' + '$c = 3' + ) + $expected = $historySelection -join "`n" + + Mock Get-PickedHistory { $historySelection } -ModuleName PsFzf + + Invoke-FzfPsReadlineHandlerHistory + + Should -Invoke 'Replace-PSConsoleReadLineText' -Times 1 -ModuleName PsFzf -ParameterFilter { + $Start -eq 0 -and $Length -eq 0 -and $ReplacementText -eq $expected + } + } + + It "Should preserve explicit backticks from history entries" { + $historySelection = @( + '$a = 1 `' + ' + 2 `' + ' + 3' + ) + $expected = $historySelection -join "`n" + + Mock Get-PickedHistory { $historySelection } -ModuleName PsFzf + + Invoke-FzfPsReadlineHandlerHistory + + Should -Invoke 'Replace-PSConsoleReadLineText' -Times 1 -ModuleName PsFzf -ParameterFilter { + $Start -eq 0 -and $Length -eq 0 -and $ReplacementText -eq $expected + } + } } }