Skip to content

Commit e795521

Browse files
Copilotkelleyma49
andauthored
Add configurable delimiter for Invoke-FzfPsReadlineHandlerProvider multi-select (#352)
* Initial plan * Add PSReadlineChordProviderDelimiter option to Set-PsFzfOption Co-authored-by: kelleyma49 <2152684+kelleyma49@users.noreply.github.com> * Update documentation for PSReadlineChordProviderDelimiter option Co-authored-by: kelleyma49 <2152684+kelleyma49@users.noreply.github.com> * Rename PSReadlineChordProviderDelimiter to PsReadlineHandlerProviderDelimiter Co-authored-by: kelleyma49 <2152684+kelleyma49@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: kelleyma49 <2152684+kelleyma49@users.noreply.github.com>
1 parent 20c1706 commit e795521

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

PSFzf.Base.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ $script:FzfLocation = $null
145145
$script:OverrideFzfDefaults = $null
146146
$script:PSReadlineHandlerChords = @()
147147
$script:TabContinuousTrigger = [IO.Path]::DirectorySeparatorChar.ToString()
148+
$script:PsReadlineHandlerProviderDelimiter = ','
148149

149150
$MyInvocation.MyCommand.ScriptBlock.Module.OnRemove =
150151
{
@@ -203,7 +204,9 @@ function Set-PsFzfOption {
203204
[string]
204205
$TabContinuousTrigger,
205206
[ScriptBlock]
206-
$AltCCommand
207+
$AltCCommand,
208+
[string]
209+
$PsReadlineHandlerProviderDelimiter
207210
)
208211
if ($PSBoundParameters.ContainsKey('TabExpansion')) {
209212
SetTabExpansion $TabExpansion
@@ -250,6 +253,10 @@ function Set-PsFzfOption {
250253
if ($PSBoundParameters.ContainsKey('AltCCommand')) {
251254
$script:AltCCommand = $AltCCommand
252255
}
256+
257+
if ($PSBoundParameters.ContainsKey('PsReadlineHandlerProviderDelimiter')) {
258+
$script:PsReadlineHandlerProviderDelimiter = $PsReadlineHandlerProviderDelimiter
259+
}
253260
}
254261

255262
function Stop-Pipeline {
@@ -810,7 +817,7 @@ function Invoke-FzfPsReadlineHandlerProvider {
810817
$result = FixCompletionResult $result
811818
}
812819

813-
$str = $result -join ','
820+
$str = $result -join $script:PsReadlineHandlerProviderDelimiter
814821
if ($addSpace) {
815822
$str = ' ' + $str
816823
}

PSFzf.tests.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,34 @@ Describe "Check Parameters" {
600600
}
601601
}
602602

603+
Describe "Set-PsFzfOption PsReadlineHandlerProviderDelimiter" {
604+
InModuleScope PsFzf {
605+
Context "Default delimiter is comma" {
606+
It "Should default to comma" {
607+
# The default delimiter should be ','
608+
$script:PsReadlineHandlerProviderDelimiter | Should -Be ','
609+
}
610+
}
611+
612+
Context "Can override delimiter" {
613+
It "Should allow setting custom delimiter" {
614+
Set-PsFzfOption -PsReadlineHandlerProviderDelimiter ' '
615+
$script:PsReadlineHandlerProviderDelimiter | Should -Be ' '
616+
}
617+
618+
It "Should allow setting to semicolon" {
619+
Set-PsFzfOption -PsReadlineHandlerProviderDelimiter ';'
620+
$script:PsReadlineHandlerProviderDelimiter | Should -Be ';'
621+
}
622+
623+
It "Should allow setting back to comma" {
624+
Set-PsFzfOption -PsReadlineHandlerProviderDelimiter ','
625+
$script:PsReadlineHandlerProviderDelimiter | Should -Be ','
626+
}
627+
}
628+
}
629+
}
630+
603631
Describe "Get-EditorLaunch" {
604632

605633

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ For day-to-day usage, see the [helper functions included with this module](https
3232

3333
Press <kbd>Ctrl+t</kbd> to start PSFzf to select provider paths. PSFzf will parse the current token and use that as the starting path to search from. If current token is empty, or the token isn't a valid path, PSFzf will search below the current working directory.
3434

35-
Multiple items can be selected. If more than one is selected by the user, the results are returned as a comma separated list. Results are properly quoted if they contain whitespace.
35+
Multiple items can be selected. If more than one is selected by the user, the results are returned as a comma separated list (the delimiter can be customized using `Set-PsFzfOption -PsReadlineHandlerProviderDelimiter`). Results are properly quoted if they contain whitespace.
3636

3737
### Reverse Search Through PSReadline History (default chord: <kbd>Ctrl+r</kbd>)
3838

docs/Set-PsFzfOption.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,28 @@ Default value: None
249249
Accept pipeline input: False
250250
Accept wildcard characters: False
251251
```
252+
253+
### -PsReadlineHandlerProviderDelimiter
254+
Specifies the delimiter character used to join multiple selected files when using the PSReadlineChordProvider (Ctrl+t by default).
255+
256+
```powershell
257+
# example - use space as delimiter instead of comma:
258+
Set-PsFzfOption -PsReadlineHandlerProviderDelimiter ' '
259+
260+
# example - use semicolon as delimiter:
261+
Set-PsFzfOption -PsReadlineHandlerProviderDelimiter ';'
262+
```
263+
```yaml
264+
Type: String
265+
Parameter Sets: (All)
266+
Aliases:
267+
268+
Required: False
269+
Position: Named
270+
Default value: ','
271+
Accept pipeline input: False
272+
Accept wildcard characters: False
273+
```
252274
## INPUTS
253275
### None
254276

0 commit comments

Comments
 (0)