Skip to content

Commit 49fdc71

Browse files
committed
fix: respect value from monaco editor props
closes vuejs#145
1 parent ef545e6 commit 49fdc71

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/monaco/Monaco.vue

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,17 @@ onMounted(async () => {
9494
}
9595
}
9696
97-
if (props.readonly) {
98-
watch(
99-
() => props.value,
100-
(value) => {
101-
editorInstance.setValue(value || '')
102-
monaco.editor.setModelLanguage(editorInstance.getModel()!, lang.value)
103-
}
104-
)
105-
} else {
97+
watch(
98+
() => props.value,
99+
(value) => editorInstance.setValue(value || ''),
100+
{ immediate: true }
101+
)
102+
103+
watch(lang, (lang) =>
104+
monaco.editor.setModelLanguage(editorInstance.getModel()!, lang)
105+
)
106+
107+
if (!props.readonly) {
106108
watch(
107109
() => props.filename,
108110
(_, oldFilename) => {

0 commit comments

Comments
 (0)