File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,8 @@ const props = defineProps<{
1616const store = inject (' store' ) as Store
1717const showMessage = ref (getItem ())
1818
19- const onChange = debounce ((code : string ) => {
20- store .state .activeFile .code = code
19+ const onChange = debounce ((code : string , filename : string ) => {
20+ store .state .files [ filename ] .code = code
2121}, 250 )
2222
2323function setItem() {
@@ -38,7 +38,7 @@ watch(showMessage, () => {
3838 <FileSelector />
3939 <div class =" editor-container" >
4040 <props .editorComponent
41- @change =" onChange"
41+ @change =" onChange($event, store.state.activeFile.filename) "
4242 :value =" store.state.activeFile.code"
4343 :filename =" store.state.activeFile.filename"
4444 />
Original file line number Diff line number Diff line change @@ -173,7 +173,9 @@ onMounted(async () => {
173173 code = prettier .format (code , options )
174174 } catch (err ) {}
175175
176- emit (' change' , code )
176+ if (code !== props .value ) {
177+ emit (' change' , code )
178+ }
177179 })
178180
179181 // update theme
You can’t perform that action at this time.
0 commit comments