mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 10:25:42 +01:00
Merge pull request #4019 from microsoft/hediet/b/right-raccoon
Repairs example urls
This commit is contained in:
commit
d514ddaa8d
2 changed files with 28 additions and 11 deletions
6
.vscode/launch.json
vendored
6
.vscode/launch.json
vendored
|
|
@ -15,6 +15,12 @@
|
|||
"order": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Website",
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"url": "http://localhost:8080/"
|
||||
},
|
||||
{
|
||||
// Clone VS Code and make sure the task "Launch Http Server" runs.
|
||||
// Then the editor is build from sources.
|
||||
|
|
|
|||
|
|
@ -322,12 +322,18 @@ function projectEquals(
|
|||
project2: IPlaygroundProject
|
||||
): boolean {
|
||||
return (
|
||||
project1.css === project2.css &&
|
||||
project1.html === project2.html &&
|
||||
project1.js === project2.js
|
||||
normalizeLineEnding(project1.css) ===
|
||||
normalizeLineEnding(project2.css) &&
|
||||
normalizeLineEnding(project1.html) ===
|
||||
normalizeLineEnding(project2.html) &&
|
||||
normalizeLineEnding(project1.js) === normalizeLineEnding(project2.js)
|
||||
);
|
||||
}
|
||||
|
||||
function normalizeLineEnding(str: string): string {
|
||||
return str.replace(/\r\n/g, "\n");
|
||||
}
|
||||
|
||||
class StateUrlSerializer implements IHistoryModel {
|
||||
public readonly dispose = Disposable.fn();
|
||||
|
||||
|
|
@ -443,16 +449,21 @@ class StateUrlSerializer implements IHistoryModel {
|
|||
this._sourceOverride = source;
|
||||
}
|
||||
|
||||
function findExample(hashValue: string): PlaygroundExample | undefined {
|
||||
if (hashValue.startsWith("example-")) {
|
||||
hashValue = hashValue.substring("example-".length);
|
||||
}
|
||||
return getPlaygroundExamples()
|
||||
.flatMap((e) => e.examples)
|
||||
.find((e) => e.id === hashValue);
|
||||
}
|
||||
|
||||
let example: PlaygroundExample | undefined;
|
||||
|
||||
if (!hashValue) {
|
||||
this.model.selectedExample = getPlaygroundExamples()[0].examples[0];
|
||||
} else if (hashValue.startsWith("example-")) {
|
||||
const exampleName = hashValue.substring("example-".length);
|
||||
const example = getPlaygroundExamples()
|
||||
.flatMap((e) => e.examples)
|
||||
.find((e) => e.id === exampleName);
|
||||
if (example) {
|
||||
} else if ((example = findExample(hashValue))) {
|
||||
this.model.selectedExample = example;
|
||||
}
|
||||
} else {
|
||||
let p: IPlaygroundProject | undefined = undefined;
|
||||
if (this.cachedState?.hash === hashValue) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue