@@ -15,15 +15,15 @@ export async function TransferFolderToCustomFolders(context: vscode.ExtensionCon
1515
1616 // 7800basic
1717 const existing7800BasicCustomFolder = config . get ( 'compiler.7800basic.folder' , null ) ;
18- if ( existing7800BasicCustomFolder ) {
18+ if ( existing7800BasicCustomFolder && ! CustomFolderExists ( seventyEightHundredCustomFoldersSection , existing7800BasicCustomFolder ) ) {
1919 // Add
2020 const customFolder = { 'Custom' : existing7800BasicCustomFolder } ;
2121 await config . update ( seventyEightHundredCustomFoldersSection , customFolder , vscode . ConfigurationTarget . Global ) ;
2222 }
2323
2424 // batariBasic
2525 const existingBatariBasicFolder = config . get ( 'compiler.batariBasic.folder' , null ) ;
26- if ( existingBatariBasicFolder ) {
26+ if ( existingBatariBasicFolder && ! CustomFolderExists ( batariBasicCustomFoldersSection , existingBatariBasicFolder ) ) {
2727 // Add
2828 const customFolder = { 'Custom' : existingBatariBasicFolder } ;
2929 await config . update ( batariBasicCustomFoldersSection , customFolder , vscode . ConfigurationTarget . Global ) ;
@@ -33,54 +33,6 @@ export async function TransferFolderToCustomFolders(context: vscode.ExtensionCon
3333 await context . globalState . update ( `${ application . Name } .configuration.transferedFolderToCustomFolders` , true )
3434}
3535
36- export function GetCustomCompilerIdList ( languageId : string ) : string [ ] {
37- // Prepare
38- const config = vscode . workspace . getConfiguration ( application . Name ) ;
39-
40- // Get
41- const customFolders = config . get < Record < string , string > > ( `compiler.${ languageId } .customFolders` , { } ) ;
42- const compilerIdList = Object . keys ( customFolders ) ?? [ ] ;
43-
44- // Return
45- return compilerIdList ;
46- }
47-
48- export function CustomFolderIdExists ( languageId : string , id : string ) : boolean {
49- // Prepare
50- const config = vscode . workspace . getConfiguration ( application . Name ) ;
51- const customFolders = config . get < Record < string , string > > ( `compiler.${ languageId } .customFolders` , { } ) ;
52- let result = false ;
53-
54- // Scan
55- for ( const [ key , value ] of Object . entries ( customFolders ) ) {
56- if ( key . toLowerCase ( ) === id . toLowerCase ( ) ) {
57- result = true ;
58- break ;
59- }
60- }
61-
62- // Return result
63- return result ;
64- }
65-
66- export function GetCustomCompilerFolder ( languageId : string , id : string ) : string {
67- // Prepare
68- const config = vscode . workspace . getConfiguration ( application . Name ) ;
69- const customFolders = config . get < Record < string , string > > ( `compiler.${ languageId } .customFolders` , { } ) ;
70- let folder = '' ;
71-
72- // Scan
73- for ( const [ key , value ] of Object . entries ( customFolders ) ) {
74- if ( key . toLowerCase ( ) === id . toLowerCase ( ) ) {
75- folder = value ;
76- break ;
77- }
78- }
79-
80- // Return result
81- return folder ;
82- }
83-
8436export async function ValidateCustomFoldersConfigurationEntry ( event : vscode . ConfigurationChangeEvent ) : Promise < void > {
8537 // Prepare
8638 const config = vscode . workspace . getConfiguration ( application . Name ) ;
@@ -106,10 +58,9 @@ export async function ValidateCustomFoldersConfigurationEntry(event: vscode.Conf
10658 if ( isChanged ) {
10759 await config . update ( seventyEightHundredCustomFoldersSection , updatedCustomFolders , vscode . ConfigurationTarget . Global ) ;
10860 }
109-
110- }
61+ } ;
11162
112- // batari Basic
63+ // batariBasic?
11364 if ( event . affectsConfiguration ( `${ application . Name } .${ batariBasicCustomFoldersSection } ` ) ) {
11465 // Prepare
11566 let customFolders = config . get < Record < string , string > > ( batariBasicCustomFoldersSection , { } ) ;
@@ -130,6 +81,53 @@ export async function ValidateCustomFoldersConfigurationEntry(event: vscode.Conf
13081 if ( isChanged ) {
13182 await config . update ( batariBasicCustomFoldersSection , updatedCustomFolders , vscode . ConfigurationTarget . Global ) ;
13283 }
133-
13484 } ;
85+ }
86+
87+ export function GetCustomCompilerIdList ( languageId : string ) : string [ ] {
88+ // Prepare
89+ const config = vscode . workspace . getConfiguration ( application . Name ) ;
90+
91+ // Get
92+ const customFolders = config . get < Record < string , string > > ( `compiler.${ languageId } .customFolders` , { } ) ;
93+ const compilerIdList = Object . keys ( customFolders ) ?? [ ] ;
94+
95+ // Return
96+ return compilerIdList ;
97+ }
98+
99+ export function GetCustomCompilerFolder ( languageId : string , id : string ) : string {
100+ // Prepare
101+ const config = vscode . workspace . getConfiguration ( application . Name ) ;
102+ const customFolders = config . get < Record < string , string > > ( `compiler.${ languageId } .customFolders` , { } ) ;
103+ let folder = '' ;
104+
105+ // Scan
106+ for ( const [ key , value ] of Object . entries ( customFolders ) ) {
107+ if ( key . toLowerCase ( ) === id . toLowerCase ( ) ) {
108+ folder = value ;
109+ break ;
110+ }
111+ }
112+
113+ // Return result
114+ return folder ;
115+ }
116+
117+ function CustomFolderExists ( configurationSection : string , folder : string ) : boolean {
118+ // Prepare
119+ const config = vscode . workspace . getConfiguration ( application . Name ) ;
120+ const customFolders = config . get < Record < string , string > > ( configurationSection , { } ) ;
121+ let result = false ;
122+
123+ // Scan
124+ for ( const [ key , value ] of Object . entries ( customFolders ) ) {
125+ if ( value . toLowerCase ( ) === folder . toLowerCase ( ) ) {
126+ result = true ;
127+ break ;
128+ }
129+ }
130+
131+ // Return result
132+ return result ;
135133}
0 commit comments