@@ -81,8 +81,7 @@ public static async Task<CommandCompletion> GetCompletionsAsync(
81
81
82
82
Stopwatch stopwatch = new ( ) ;
83
83
84
- CommandCompletion commandCompletion = null ;
85
- await executionService . ExecuteDelegateAsync (
84
+ CommandCompletion ? commandCompletion = await executionService . ExecuteDelegateAsync (
86
85
representation : "CompleteInput" ,
87
86
new ExecutionOptions { Priority = ExecutionPriority . Next } ,
88
87
( pwsh , _ ) =>
@@ -108,15 +107,14 @@ await executionService.ExecuteDelegateAsync(
108
107
109
108
if ( completionResults is { Count : > 0 } )
110
109
{
111
- commandCompletion = completionResults [ 0 ] ;
110
+ return completionResults [ 0 ] ;
112
111
}
113
-
114
- return ;
112
+ return null ;
115
113
}
116
114
117
115
// If the current runspace is out of process, we can't call TabExpansion2
118
116
// because the output will be serialized.
119
- commandCompletion = CommandCompletion . CompleteInput (
117
+ return CommandCompletion . CompleteInput (
120
118
scriptAst ,
121
119
currentTokens ,
122
120
cursorPosition ,
@@ -126,7 +124,13 @@ await executionService.ExecuteDelegateAsync(
126
124
cancellationToken )
127
125
. ConfigureAwait ( false ) ;
128
126
129
- stopwatch . Stop ( ) ;
127
+ stopwatch . Stop ( ) ;
128
+ if ( commandCompletion is null )
129
+ {
130
+ logger . LogError ( "Error Occurred in tabexpansion2" ) ;
131
+ }
132
+ else
133
+ {
130
134
logger . LogTrace (
131
135
"IntelliSense completed in {elapsed}ms - WordToComplete: \" {word}\" MatchCount: {count}" ,
132
136
stopwatch . ElapsedMilliseconds ,
@@ -136,7 +140,7 @@ await executionService.ExecuteDelegateAsync(
136
140
commandCompletion . ReplacementLength )
137
141
: null ,
138
142
commandCompletion . CompletionMatches . Count ) ;
139
-
143
+ }
140
144
return commandCompletion ;
141
145
}
142
146
0 commit comments