@@ -976,6 +976,41 @@ main() {
976
976
''' ));
977
977
}
978
978
979
+ /// This test reproduces a bug where the pathKey hash used in
980
+ /// available_declarations.dart would not change with the contents of the file
981
+ /// (as it always used 0 as the modification stamp) which would prevent
982
+ /// completion including items from files that were open (had overlays).
983
+ /// https://github.com/Dart-Code/Dart-Code/issues/2286#issuecomment-658597532
984
+ Future <void > test_suggestionSets_modifiedFiles () async {
985
+ final otherFilePath = join (projectFolderPath, 'lib' , 'other_file.dart' );
986
+ final otherFileUri = Uri .file (otherFilePath);
987
+
988
+ final mainFileContent = 'MyOtherClass^' ;
989
+ final initialAnalysis = waitForAnalysisComplete ();
990
+ await initialize (
991
+ workspaceCapabilities:
992
+ withApplyEditSupport (emptyWorkspaceClientCapabilities));
993
+ await openFile (mainFileUri, withoutMarkers (mainFileContent));
994
+ await initialAnalysis;
995
+
996
+ // Start with a blank file.
997
+ newFile (otherFilePath, content: '' );
998
+ await openFile (otherFileUri, '' );
999
+ await pumpEventQueue (times: 5000 );
1000
+
1001
+ // Reopen the file with a class definition.
1002
+ await closeFile (otherFileUri);
1003
+ await openFile (otherFileUri, 'class MyOtherClass {}' );
1004
+ await pumpEventQueue (times: 5000 );
1005
+
1006
+ // Ensure the class appears in completion.
1007
+ final completions =
1008
+ await getCompletion (mainFileUri, positionFromMarker (mainFileContent));
1009
+ final matching =
1010
+ completions.where ((c) => c.label == 'MyOtherClass' ).toList ();
1011
+ expect (matching, hasLength (1 ));
1012
+ }
1013
+
979
1014
Future <void > test_suggestionSets_namedConstructors () async {
980
1015
newFile (
981
1016
join (projectFolderPath, 'other_file.dart' ),
0 commit comments