@@ -62,6 +62,44 @@ public void hotReloadExtractionUsesSourceMap() throws Exception {
6262 assertEquals (Files .readString (scriptFile .toPath ()), "source script" );
6363 }
6464
65+ @ Test
66+ public void mapScriptIsExtractedWhenWorkspaceScriptIsMissingDespiteStaticCacheHit () throws Exception {
67+ File projectFolder = new File ("./temp/testProject_extract_missing_script/" );
68+ File wurstFolder = new File (projectFolder , "wurst" );
69+ newCleanFolder (wurstFolder );
70+
71+ File sourceMap = new File (projectFolder , "source_map.w3x" );
72+ Files .write (sourceMap .toPath (), new byte [] {0x01 });
73+
74+ WurstLanguageServer langServer = new WurstLanguageServer ();
75+ TestMapRequest request = new TestMapRequest (
76+ langServer ,
77+ Optional .of (sourceMap ),
78+ List .of (),
79+ WFile .create (projectFolder ),
80+ Map .of (sourceMap , "fresh map script" .getBytes (StandardCharsets .UTF_8 ))
81+ );
82+
83+ MapRequest .mapLastModified = sourceMap .lastModified ();
84+ MapRequest .mapPath = sourceMap .getAbsolutePath ();
85+
86+ File firstExtract = request .loadMapScriptForTest (
87+ Optional .of (sourceMap ),
88+ new ModelManagerImpl (projectFolder , new BufferManager ()),
89+ new WurstGuiLogger ()
90+ );
91+ assertEquals (Files .readString (firstExtract .toPath ()), "fresh map script" );
92+
93+ Files .delete (firstExtract .toPath ());
94+ File secondExtract = request .loadMapScriptForTest (
95+ Optional .of (sourceMap ),
96+ new ModelManagerImpl (projectFolder , new BufferManager ()),
97+ new WurstGuiLogger ()
98+ );
99+
100+ assertEquals (Files .readString (secondExtract .toPath ()), "fresh map script" );
101+ }
102+
65103 @ Test
66104 public void cachedMapFileNameIsModeSpecific () throws Exception {
67105 File projectFolder = new File ("./temp/testProject_cache_mode_specific/" );
0 commit comments