Skip to content

Commit 5ec224f

Browse files
committed
Fix: fixed code pane was unstable
1 parent f9ca7df commit 5ec224f

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/code-editor.vue

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const EDITOR_OPTS = {
1414
autoFindInSelection: true,
1515
seedSearchStringFromSelection: true,
1616
},
17-
formatOnPaste: true,
1817
renderControlCharacters: true,
1918
renderIndentGuides: true,
2019
renderWhitespace: "boundary",
@@ -158,13 +157,15 @@ export default {
158157
return {
159158
editor: null,
160159
ready: ready.then(this.initialize),
161-
invalidate: debounce(() => {
160+
editing: false,
161+
invalidate_: debounce(() => {
162162
const editor = this.codeEditor
163163
if (editor != null) {
164164
const model = editor.getModel()
165165
const value = model.getValue()
166166
this.$emit("edit", value)
167167
}
168+
this.editing = false
168169
}, 667),
169170
}
170171
},
@@ -188,6 +189,14 @@ export default {
188189
}
189190
return null
190191
},
192+
193+
actualFixedCode() {
194+
const editor = this.codeEditor
195+
if (this.editing && editor != null) {
196+
return editor.getModel().getValue()
197+
}
198+
return this.fixedCode
199+
},
191200
},
192201
193202
watch: {
@@ -198,7 +207,7 @@ export default {
198207
}
199208
},
200209
201-
fixedCode(value) {
210+
actualFixedCode(value) {
202211
const editor = this.fixedCodeEditor
203212
if (editor != null) {
204213
updateValue(editor, value)
@@ -273,7 +282,6 @@ export default {
273282
274283
// Set change event.
275284
original.onDidChangeContent(() => {
276-
updateValue(rightEditor, original.getValue())
277285
this.invalidate()
278286
})
279287
@@ -286,6 +294,11 @@ export default {
286294
287295
return editor
288296
},
297+
298+
invalidate() {
299+
this.editing = true
300+
this.invalidate_()
301+
},
289302
},
290303
}
291304
</script>

0 commit comments

Comments
 (0)