diff --git a/lib/clientstate-normalizer.ts b/lib/clientstate-normalizer.ts index 5b44edccb..dec7b5db1 100644 --- a/lib/clientstate-normalizer.ts +++ b/lib/clientstate-normalizer.ts @@ -339,7 +339,10 @@ export class ClientStateNormalizer { const session = this.normalized.findSessionById(file.editorId); if (session) { file.content = session.source; - file.filename = session.filename; + if (!file.filename && session.filename) { + // it's fine if the session doesn't contain the filename, the filename in the tree is always leading + file.filename = session.filename; + } } } } diff --git a/lib/handlers/route-api.ts b/lib/handlers/route-api.ts index b2f7caff4..a1ddb6b7e 100644 --- a/lib/handlers/route-api.ts +++ b/lib/handlers/route-api.ts @@ -29,7 +29,7 @@ import express from 'express'; import {AppDefaultArguments, CompilerExplorerOptions} from '../../app.js'; import {isString} from '../../shared/common-utils.js'; import {Language} from '../../types/languages.interfaces.js'; -import {assert, unwrap} from '../assert.js'; +import {assert} from '../assert.js'; import {ClientStateGoldenifier, ClientStateNormalizer} from '../clientstate-normalizer.js'; import {ClientState} from '../clientstate.js'; import {CompilationEnvironment} from '../compilation-env.js'; @@ -281,7 +281,7 @@ export class RouteAPI { if (tree.isCMakeProject) { const firstSource = tree.files.find(file => { - return unwrap(file.filename).startsWith('CMakeLists.txt'); + return file.filename?.startsWith('CMakeLists.txt'); }); if (firstSource) { @@ -289,7 +289,7 @@ export class RouteAPI { } } else { const firstSource = tree.files.find(file => { - return unwrap(file.filename).startsWith('example.'); + return file.filename?.startsWith('example.'); }); if (firstSource) {