Skip to content

Commit 28b492f

Browse files
committed
Changed behavior for case git diff: git displays a better help outside of repositories, so execute git in TEMP instead of the current dir
1 parent a1d45c7 commit 28b492f

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/GitHintTabExpansion.ps1

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function Get-GITModeHint {
3232
}
3333
$script:paramHints.$Command.add("*", $modeTable)
3434
}
35-
35+
3636
# Create the results
3737
if ($script:paramHints.$Command."*".containsKey($Mode))
3838
{
@@ -62,28 +62,19 @@ function Get-GITParameterHint {
6262
if (-not $script:paramHints.containsKey($Command)) { $script:paramHints.add($Command, @{}) }
6363
# Populate the "mode branch" if empty
6464
if (-not $script:paramHints.$Command.containsKey($Mode)) {
65-
$helpStrings = Invoke-Utf8ConsoleCommand { & $Command $Mode -h 2>&1 }
66-
$exceptions = @("diff")
65+
$helpStrings = Invoke-Utf8ConsoleCommand { & $Command -C "$($env:temp)" --no-pager $Mode -h 2>&1 }
6766
$preProcessedStrings = @()
6867
# Preprocessing
6968
foreach ($line in $helpStrings)
7069
{
7170
switch -RegEx ($line) {
72-
"^\s{2,2}(-.*)$" {
73-
# this a line defining a parameter, if we are in git diff
74-
if ($Mode -like "diff") { $preProcessedStrings += "$($Matches[1])" }
75-
}
76-
"^\s{15,15}(\s.*)$" {
77-
# this line belongs to the parameter description of the line before in git diff
78-
if ($Mode -like "diff") { $preProcessedStrings[-1] = "$($preProcessedStrings[-1])$($Matches[1])" }
79-
}
8071
"^\s{4,4}(-.*)$" {
8172
# this is a line defining a parameter
82-
if ($Mode -notin $exceptions) { $preProcessedStrings += "$($Matches[1])" }
73+
$preProcessedStrings += "$($Matches[1])"
8374
}
8475
"^\s{25,25}(\s.*)$" {
8576
# this line belongs to the parameter description of the line before
86-
if ($Mode -notin $exceptions) { $preProcessedStrings[-1] = "$($preProcessedStrings[-1])$($Matches[1])" }
77+
$preProcessedStrings[-1] = "$($preProcessedStrings[-1])$($Matches[1])"
8778
}
8879
}
8980
}
@@ -171,7 +162,7 @@ function Add-HintsToParams {
171162

172163
# We are only handling git at the moment
173164
if ($Command -notmatch "^$(Get-AliasPattern git) (.*)") { return $PossibleParams }
174-
165+
175166
# Determing git mode, which is the first parameter without dashes, but not the last one, which is "" or an incomplete parameter
176167
$cmdMode = $null
177168
for ($i=1; $i -lt $cmdParts.length-1; $i++) {
@@ -180,7 +171,7 @@ function Add-HintsToParams {
180171
break
181172
}
182173
}
183-
174+
184175
$newTabCompletions = @()
185176
if ($cmdMode) {
186177
# we're searching a parameter for mode $cmdMode

0 commit comments

Comments
 (0)