@@ -7,21 +7,19 @@ export class MonacoSongEditor extends MonacoReactFieldEditor<pxt.Song> {
77 protected isPython : boolean ;
88 protected isAsset : boolean ;
99 protected text : string ;
10- protected editing : pxt . Asset ;
1110
1211 protected textToValue ( text : string ) : pxt . Song {
1312 this . isPython = text . indexOf ( "`" ) === - 1
1413 this . text = text ;
1514
1615 const match = pxt . parseAssetTSReference ( text ) ;
1716 if ( match ) {
18- const { name : matchedName } = match ;
17+ const { type , name : matchedName } = match ;
1918 const name = matchedName . trim ( ) ;
2019 const project = pxt . react . getTilemapProject ( ) ;
2120 this . isAsset = true ;
2221 const asset = project . lookupAssetByName ( pxt . AssetType . Song , name ) ;
2322 if ( asset ) {
24- this . editing = asset ;
2523 return asset ;
2624 }
2725 else {
@@ -31,8 +29,6 @@ export class MonacoSongEditor extends MonacoReactFieldEditor<pxt.Song> {
3129 newAsset . meta . displayName = name ;
3230 }
3331
34- this . editing = newAsset ;
35-
3632 return newAsset ;
3733 }
3834 }
@@ -43,24 +39,18 @@ export class MonacoSongEditor extends MonacoReactFieldEditor<pxt.Song> {
4339 const contents = hexLiteralMatch [ 1 ] . trim ( ) ;
4440
4541 if ( contents ) {
46- this . editing = createFakeAsset ( pxt . assets . music . decodeSongFromHex ( contents ) ) ;
47- }
48- else {
49- this . editing = createFakeAsset ( pxt . assets . music . getEmptySong ( 2 ) ) ;
42+ return createFakeAsset ( pxt . assets . music . decodeSongFromHex ( contents ) ) ;
5043 }
5144
52- return this . editing ;
45+ return createFakeAsset ( pxt . assets . music . getEmptySong ( 2 ) ) ;
5346 }
5447
5548 return undefined ; // never
5649 }
5750
5851 protected resultToText ( result : pxt . Song ) : string {
59- const project = pxt . react . getTilemapProject ( ) ;
60- project . pushUndo ( ) ;
61-
62- result = pxt . patchTemporaryAsset ( this . editing , result , project ) as pxt . Song ;
6352 if ( result . meta ?. displayName ) {
53+ const project = pxt . react . getTilemapProject ( ) ;
6454 if ( this . isAsset || project . lookupAsset ( result . type , result . id ) ) {
6555 result = project . updateAsset ( result )
6656 } else {
0 commit comments