@@ -7,15 +7,10 @@ import * as statusBar from './statusBar';
77import * as Diag from '../diagnose/main' ;
88import * as conf from '../utils/configuration' ;
99import { messageCollector } from '../diagnose/messageCollector' ;
10+ import { logger } from '../utils/logger' ;
1011
1112const fs = vscode . workspace . fs ;
1213
13- enum actionType {
14- open ,
15- run ,
16- debug
17- }
18-
1914type ACTIONS = {
2015 [ id : string ] : {
2116 baseBundle : string ,
@@ -41,7 +36,8 @@ export async function activate(context: vscode.ExtensionContext) {
4136 const assemblyToolsFolder = vscode . Uri . joinPath ( context . globalStorageUri , conf . extConf . asmType ) ;
4237 const seperateSpaceFolder = vscode . Uri . joinPath ( context . globalStorageUri , "workspace" ) ;
4338
44- async function singleFileMode ( type : actionType , _uri : vscode . Uri ) : Promise < AsmResult > {
39+ async function singleFileMode ( act : conf . actionType , _uri : vscode . Uri ) : Promise < AsmResult > {
40+ logger . actionLog ( act , _uri ) ;
4541
4642 if ( nodefs . existsSync ( seperateSpaceFolder . fsPath ) ) {
4743 await fs . delete ( seperateSpaceFolder , { recursive : true , useTrash : false } ) ;
@@ -95,10 +91,10 @@ export async function activate(context: vscode.ExtensionContext) {
9591 }
9692 return r + " >>C:\\" + logFilename ;
9793 }
98- if ( type === actionType . run ) {
94+ if ( act === conf . actionType . run ) {
9995 autoexec . push ( ...action . run . map ( cb ) ) ;
10096 }
101- if ( type === actionType . debug ) {
97+ if ( act === conf . actionType . debug ) {
10298 autoexec . push ( ...action . debug . map ( cb ) ) ;
10399 }
104100
@@ -108,7 +104,7 @@ export async function activate(context: vscode.ExtensionContext) {
108104 await box . fromBundle ( bundle , assemblyToolsFolder ) ;
109105 box . updateAutoexec ( autoexec ) ;
110106
111- if ( type !== actionType . open ) {
107+ if ( act !== conf . actionType . open ) {
112108 const [ hook , promise ] = messageCollector ( ) ;
113109 nodefs . watchFile ( logUri . fsPath , ( ) => {
114110 try {
@@ -153,15 +149,15 @@ export async function activate(context: vscode.ExtensionContext) {
153149 }
154150 return r ;
155151 }
156- if ( type === actionType . run ) {
152+ if ( act === conf . actionType . run ) {
157153 autoexec . push ( ...action . run . map ( cb ) ) ;
158154 }
159- if ( type === actionType . debug ) {
155+ if ( act === conf . actionType . debug ) {
160156 autoexec . push ( ...action . debug . map ( cb ) ) ;
161157 }
162158 api . jsdos . updateAutoexec ( autoexec ) ;
163159 const webview = await api . jsdos . runInWebview ( ) ;
164- if ( type !== actionType . open ) {
160+ if ( act !== conf . actionType . open ) {
165161 const [ hook , promise ] = messageCollector ( ) ;
166162 webview . onDidReceiveMessage ( e => {
167163 switch ( e . command ) {
@@ -184,7 +180,7 @@ export async function activate(context: vscode.ExtensionContext) {
184180 ( terminal as vscode . Terminal ) . sendText ( val . replace ( 'C:' , assemblyToolsFolder . fsPath ) ) ;
185181 }
186182 ) ;
187- if ( type === actionType . open ) {
183+ if ( act === conf . actionType . open ) {
188184 terminal . sendText ( `cd "${ vscode . Uri . joinPath ( _uri , '..' ) . fsPath } "` ) ;
189185 }
190186 else {
@@ -199,10 +195,10 @@ export async function activate(context: vscode.ExtensionContext) {
199195 return r + `>> ${ logFilename } \n type ${ logFilename } ` ;
200196 }
201197 }
202- if ( type === actionType . run ) {
198+ if ( act === conf . actionType . run ) {
203199 action . run . map ( cb ) . forEach ( val => ( terminal as vscode . Terminal ) . sendText ( val ) ) ;
204200 }
205- if ( type === actionType . debug ) {
201+ if ( act === conf . actionType . debug ) {
206202 action . debug . map ( cb ) . forEach ( val => ( terminal as vscode . Terminal ) . sendText ( val ) ) ;
207203 }
208204 const logUri = vscode . Uri . joinPath ( folder , logFilename ) ;
@@ -234,8 +230,8 @@ export async function activate(context: vscode.ExtensionContext) {
234230 }
235231
236232 context . subscriptions . push (
237- vscode . commands . registerCommand ( 'masm-tasm.openEmulator' , ( uri : vscode . Uri ) => singleFileMode ( actionType . open , uri ) ) ,
238- vscode . commands . registerCommand ( 'masm-tasm.runASM' , ( uri : vscode . Uri ) => singleFileMode ( actionType . run , uri ) ) ,
239- vscode . commands . registerCommand ( 'masm-tasm.debugASM' , ( uri : vscode . Uri ) => singleFileMode ( actionType . debug , uri ) )
233+ vscode . commands . registerCommand ( 'masm-tasm.openEmulator' , ( uri : vscode . Uri ) => singleFileMode ( conf . actionType . open , uri ) ) ,
234+ vscode . commands . registerCommand ( 'masm-tasm.runASM' , ( uri : vscode . Uri ) => singleFileMode ( conf . actionType . run , uri ) ) ,
235+ vscode . commands . registerCommand ( 'masm-tasm.debugASM' , ( uri : vscode . Uri ) => singleFileMode ( conf . actionType . debug , uri ) )
240236 ) ;
241237}
0 commit comments