proposed fix for #59

This commit is contained in:
Vaclav Barta
2022-01-20 10:18:44 +01:00
parent fd479d8671
commit 1f334d6253
2 changed files with 5 additions and 4 deletions

View File

@@ -71,7 +71,7 @@ const HooksEditor = () => {
keepCurrentModel
defaultLanguage={snap.files?.[snap.active]?.language}
language={snap.files?.[snap.active]?.language}
path={`file://work/c/${snap.files?.[snap.active]?.name}`}
path={`file:///work/c/${snap.files?.[snap.active]?.name}`}
defaultValue={snap.files?.[snap.active]?.content}
beforeMount={monaco => {
if (!snap.editorCtx) {
@@ -79,7 +79,7 @@ const HooksEditor = () => {
monaco.editor.createModel(
file.content,
file.language,
monaco.Uri.parse(`file://work/c/${file.name}`)
monaco.Uri.parse(`file:///work/c/${file.name}`)
)
);
}

View File

@@ -4,8 +4,9 @@ import state from '../index';
// Saves the current editor content to global state
export const saveFile = (showToast: boolean = true) => {
const editorModels = state.editorCtx?.getModels();
const sought = state.files[state.active].name;
const currentModel = editorModels?.find((editorModel) => {
return editorModel.uri.path === `/c/${state.files[state.active].name}`;
return editorModel.uri.path.endsWith(sought);
});
if (state.files.length > 0) {
state.files[state.active].content = currentModel?.getValue() || "";