Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/code-editor/documents/documents-load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ editor.once('load', () => {

// ready to sync
doc.on('load', () => {
if (!doc.type) {
return;
}

// check if closed by the user
if (!documentsIndex[id]) {
return;
Expand Down Expand Up @@ -103,7 +107,7 @@ editor.once('load', () => {
if (importingAssetPath) {
// Return the immediate dependencies of the asset
const deps = editor.call('utils:deps-from-string', content, importingAssetPath);
const depsAsAsset = Array.from(deps).map(path => editor.call('assets:getByVirtualPath', path));
const depsAsAsset = Array.from(deps).map(path => editor.call('assets:getByVirtualPath', path)).filter(Boolean);

// And load them, ensuring that Monaco can resolve dependencies
depsAsAsset.forEach(asset => loadDocument(asset, false));
Expand Down
2 changes: 1 addition & 1 deletion src/code-editor/files-panel/files-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ editor.once('load', () => {
// Select file by id (which can be passed as a string or number)
editor.method('files:select', (id: number|string) => {
const item = idToItem.get(String(id));
if (item) {
if (item && !item.destroyed) {
tree.deselect();
item.selected = true;
}
Expand Down
12 changes: 7 additions & 5 deletions src/code-editor/monaco/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,14 @@ editor.once('load', () => {
}

const assetPath = asset.get('path');
const pathAssets = assetPath.map(id => editor.call('assets:get', id));
if (pathAssets.some(a => !a)) {
// Parent folder(s) have been deleted, skip loading
return;
const pathSegments = [];
for (const id of assetPath) {
const a = editor.call('assets:get', id);
if (!a) {
return;
}
pathSegments.push(a.get('name'));
}
const pathSegments = pathAssets.map(a => a.get('name'));
const path = [...pathSegments, asset.get('file').filename].join('/');

const uri = monaco.Uri.parse(`${path}`);
Expand Down