@@ -2,18 +2,30 @@ Import-Module PSReadLine
2
2
Set-PSReadLineKeyHandler - Chord Tab - Function MenuComplete
3
3
$scriptblock = {
4
4
param ($wordToComplete , $commandAst , $cursorPosition )
5
- $Env :% (autocomplete_var)s = " complete_powershell"
6
- $Env: _TYPER_COMPLETE_ARGS = $commandAst.ToString ()
7
- $Env: _TYPER_COMPLETE_WORD_TO_COMPLETE = $wordToComplete
8
- {{ manage_script }} {{ django_command }} {{ color }} complete | ForEach-Object {
5
+
6
+ $commandText = $commandAst.Extent.Text
7
+
8
+ # trailing white space is lopped off, add it back if necessary
9
+ if ($cursorPosition -gt $commandText.Length ) {
10
+ $commandText += " "
11
+ }
12
+
13
+ $settingsOption = " "
14
+ if ($commandText -match " --settings(?:\s+|=)([^\s]+)\s+" ) {
15
+ $settingsOption = " --settings=$ ( $matches [1 ]) "
16
+ }
17
+
18
+ $pythonPathOption = " "
19
+ if ($commandText -match " --pythonpath(?:\s+|=)([^\s]+)\s+" ) {
20
+ $pythonPathOption = " --pythonpath=$ ( $matches [1 ]) "
21
+ }
22
+
23
+ {{ manage_script_name }} {{ django_command }} $settingsOption $pythonPathOption -- shell {{ shell }} {{ color }} complete " $ ( $commandText ) " | ForEach-Object {
9
24
$commandArray = $_ -Split " :::"
10
25
$command = $commandArray [0 ]
11
26
$helpString = $commandArray [1 ]
12
27
[System.Management.Automation.CompletionResult ]::new(
13
28
$command , $command , ' ParameterValue' , $helpString )
14
29
}
15
- $Env :% (autocomplete_var)s = " "
16
- $Env: _TYPER_COMPLETE_ARGS = " "
17
- $Env: _TYPER_COMPLETE_WORD_TO_COMPLETE = " "
18
30
}
19
- Register-ArgumentCompleter - Native - CommandName % (prog_name)s - ScriptBlock $scriptblock
31
+ Register-ArgumentCompleter - Native - CommandName {{ manage_script_name }} - ScriptBlock $scriptblock
0 commit comments