Skip to content

Commit

Permalink
fix(code-editor): prevent "undefined" content in files (#11435)
Browse files Browse the repository at this point in the history
  • Loading branch information
allardy committed Feb 9, 2022
1 parent 9c12f7b commit ba22305
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/code-editor/src/views/full/store/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class CodeEditorApi {
const { data } = await this.axios.post('/mod/code-editor/readFile', file)
return data.fileContent
} catch (err) {
this.handleApiError(err, 'Could not check if file already exists')
this.handleApiError(err, 'Error while reading file')
}
}

Expand Down
4 changes: 4 additions & 0 deletions modules/code-editor/src/views/full/store/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ class EditorStore {
}
}

if (file.content === undefined) {
return
}

runInAction('-> openFile', () => {
const uri = getFileUri(file)
const existingFile = this.openedFiles.find(x => x.uri.path === uri.path)
Expand Down

0 comments on commit ba22305

Please sign in to comment.