@@ -76,13 +76,10 @@ public static async Task<CommandCompletion> GetCompletionsAsync(
76
76
CancellationToken cancellationToken )
77
77
{
78
78
IScriptPosition cursorPosition = s_clonePositionWithNewOffset ( scriptAst . Extent . StartScriptPosition , fileOffset ) ;
79
-
80
- logger . LogTrace ( $ "Getting completions at offset { fileOffset } (line: { cursorPosition . LineNumber } , column: { cursorPosition . ColumnNumber } )") ;
81
-
82
79
Stopwatch stopwatch = new ( ) ;
80
+ logger . LogTrace ( $ "Getting completions at offset { fileOffset } (line: { cursorPosition . LineNumber } , column: { cursorPosition . ColumnNumber } )") ;
83
81
84
- CommandCompletion commandCompletion = null ;
85
- await executionService . ExecuteDelegateAsync (
82
+ CommandCompletion commandCompletion = await executionService . ExecuteDelegateAsync (
86
83
representation : "CompleteInput" ,
87
84
new ExecutionOptions { Priority = ExecutionPriority . Next } ,
88
85
( pwsh , _ ) =>
@@ -108,35 +105,41 @@ await executionService.ExecuteDelegateAsync(
108
105
109
106
if ( completionResults is { Count : > 0 } )
110
107
{
111
- commandCompletion = completionResults [ 0 ] ;
108
+ return completionResults [ 0 ] ;
112
109
}
113
110
114
- return ;
111
+ return null ;
115
112
}
116
113
117
114
// If the current runspace is out of process, we can't call TabExpansion2
118
115
// because the output will be serialized.
119
- commandCompletion = CommandCompletion . CompleteInput (
116
+ return CommandCompletion . CompleteInput (
120
117
scriptAst ,
121
118
currentTokens ,
122
119
cursorPosition ,
123
120
options : null ,
124
121
powershell : pwsh ) ;
125
122
} ,
126
- cancellationToken )
127
- . ConfigureAwait ( false ) ;
123
+ cancellationToken ) . ConfigureAwait ( false ) ;
128
124
129
125
stopwatch . Stop ( ) ;
130
- logger . LogTrace (
131
- "IntelliSense completed in {elapsed}ms - WordToComplete: \" {word}\" MatchCount: {count}" ,
132
- stopwatch . ElapsedMilliseconds ,
133
- commandCompletion . ReplacementLength > 0
134
- ? scriptAst . Extent . StartScriptPosition . GetFullScript ( ) ? . Substring (
135
- commandCompletion . ReplacementIndex ,
136
- commandCompletion . ReplacementLength )
137
- : null ,
138
- commandCompletion . CompletionMatches . Count ) ;
139
126
127
+ if ( commandCompletion is null )
128
+ {
129
+ logger . LogError ( "Error Occurred in TabExpansion2" ) ;
130
+ }
131
+ else
132
+ {
133
+ logger . LogTrace (
134
+ "IntelliSense completed in {elapsed}ms - WordToComplete: \" {word}\" MatchCount: {count}" ,
135
+ stopwatch . ElapsedMilliseconds ,
136
+ commandCompletion . ReplacementLength > 0
137
+ ? scriptAst . Extent . StartScriptPosition . GetFullScript ( ) ? . Substring (
138
+ commandCompletion . ReplacementIndex ,
139
+ commandCompletion . ReplacementLength )
140
+ : null ,
141
+ commandCompletion . CompletionMatches . Count ) ;
142
+ }
140
143
return commandCompletion ;
141
144
}
142
145
0 commit comments