Skip to content

Commit

Permalink
Fixes existing tab completion if dashed parameter for git (e.g. -p, -…
Browse files Browse the repository at this point in the history
…P) is used
  • Loading branch information
dodmi committed Dec 26, 2024
1 parent bbc5ac3 commit 5a5cedb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/GitTabExpansion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ function Expand-GitCommand($Command) {
function GitTabExpansionInternal($lastBlock, $GitStatus = $null) {
$ignoreGitParams = '(?<params>\s+-(?:[aA-zZ0-9]+|-[aA-zZ0-9][aA-zZ0-9-]*)(?:=\S+)?)*'

# Remove direct git parameters like -p, -P
# @ToDo: doesn't work with parameters followed by a value like -C <path>
if ($lastBlock -match "\s*(\S+\s)\s*((?:-\S+\s)*)([^-]\S+.*)") {
$lastBlock = $matches[1] + $matches[3]
}

if ($lastBlock -match "^$(Get-AliasPattern git) (?<cmd>\S+)(?<args> .*)$") {
$lastBlock = expandGitAlias $Matches['cmd'] $Matches['args']
}
Expand Down

0 comments on commit 5a5cedb

Please sign in to comment.