@@ -38,6 +38,7 @@ public class LanguageServerProtocolMessageTests : IClassFixture<LSPTestsFixture>
38
38
Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
39
39
40
40
private readonly ILanguageClient PsesLanguageClient ;
41
+ private readonly List < LogMessageParams > Messages ;
41
42
private readonly List < Diagnostic > Diagnostics ;
42
43
private readonly List < PsesTelemetryEvent > TelemetryEvents ;
43
44
private readonly string PwshExe ;
@@ -46,6 +47,8 @@ public LanguageServerProtocolMessageTests(ITestOutputHelper output, LSPTestsFixt
46
47
{
47
48
data . Output = output ;
48
49
PsesLanguageClient = data . PsesLanguageClient ;
50
+ Messages = data . Messages ;
51
+ Messages . Clear ( ) ;
49
52
Diagnostics = data . Diagnostics ;
50
53
Diagnostics . Clear ( ) ;
51
54
TelemetryEvents = data . TelemetryEvents ;
@@ -957,6 +960,36 @@ public async Task CanSendCompletionAndCompletionResolveRequestAsync()
957
960
Assert . Contains ( "Writes customized output to a host" , updatedCompletionItem . Documentation . String ) ;
958
961
}
959
962
963
+ // Regression test for https://github.com/PowerShell/PowerShellEditorServices/issues/1926
964
+ [ SkippableFact ]
965
+ public async Task CanRequestCompletionsAndHandleExceptions ( )
966
+ {
967
+ Skip . IfNot ( VersionUtils . PSEdition == "Core" , "This is a temporary bug in PowerShell 7, the fix is making its way upstream." ) ;
968
+ string filePath = NewTestFile ( @"
969
+ @() | ForEach-Object {
970
+ if ($false) {
971
+ return
972
+ }
973
+
974
+ @{key=$}
975
+ }" ) ;
976
+
977
+ Messages . Clear ( ) ; // On some systems there's a warning message about configuration items too.
978
+ CompletionList completionItems = await PsesLanguageClient . TextDocument . RequestCompletion (
979
+ new CompletionParams
980
+ {
981
+ TextDocument = new TextDocumentIdentifier
982
+ {
983
+ Uri = DocumentUri . FromFileSystemPath ( filePath )
984
+ } ,
985
+ Position = new Position ( line : 6 , character : 11 )
986
+ } ) ;
987
+
988
+ Assert . Empty ( completionItems ) ;
989
+ LogMessageParams message = Assert . Single ( Messages ) ;
990
+ Assert . Contains ( "Exception occurred while running handling completion request" , message . Message ) ;
991
+ }
992
+
960
993
[ SkippableFact ( Skip = "Completion for Expand-SlowArchive is flaky." ) ]
961
994
public async Task CanSendCompletionResolveWithModulePrefixRequestAsync ( )
962
995
{
0 commit comments