Skip to content

Commit

Permalink
Missing tree filenames short link fix (compiler-explorer#7379)
Browse files Browse the repository at this point in the history
  • Loading branch information
partouf authored Feb 8, 2025
1 parent 877aa55 commit ea1c667
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/clientstate-normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/handlers/route-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -281,15 +281,15 @@ 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) {
source = firstSource.content;
}
} else {
const firstSource = tree.files.find(file => {
return unwrap(file.filename).startsWith('example.');
return file.filename?.startsWith('example.');
});

if (firstSource) {
Expand Down

0 comments on commit ea1c667

Please sign in to comment.