From ea1c667c30bf2479bb2eb886027c6f06852c6e40 Mon Sep 17 00:00:00 2001 From: Patrick Quist Date: Sat, 8 Feb 2025 16:12:40 +0100 Subject: [PATCH] Missing tree filenames short link fix (#7379) --- lib/clientstate-normalizer.ts | 5 ++++- lib/handlers/route-api.ts | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/clientstate-normalizer.ts b/lib/clientstate-normalizer.ts index 5b44edccb09..dec7b5db1fe 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 b2f7caff4a0..a1ddb6b7e02 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) {