File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,13 +16,22 @@ export function convert (outputChannel: vscode.OutputChannel) : TokenizedBASICFi
1616 const outputRelativeDir : string | undefined = configuration . get ( "convertOutputDir" ) ;
1717 const command : string | undefined = configuration . get ( "petcat" ) ;
1818 if ( command && fs . existsSync ( command ) ) {
19- const rootFolder = vscode . workspace . workspaceFolders ? path . normalize ( vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath ) : undefined ;
19+ let rootFolder = vscode . workspace . workspaceFolders ? path . normalize ( vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath ) : undefined ;
20+ if ( ! rootFolder ) {
21+ const workspaceFolders = vscode . workspace . textDocuments . map ( doc => path . dirname ( doc . fileName ) ) ;
22+ if ( workspaceFolders . length > 0 ) {
23+ rootFolder = workspaceFolders [ 0 ] ;
24+ }
25+ }
2026 const fileBasename = path . basename ( document . fileName ) ;
2127 const fileExt = path . extname ( document . fileName ) ;
2228 if ( utils . isC64basicv2Extension ( fileExt ) ) {
2329 const outputDir = `${ rootFolder } ${ path . sep } ${ outputRelativeDir } ` ;
24-
2530 const outputFile = `${ outputDir } ${ path . sep } ${ fileBasename } ` ;
31+ if ( ! fs . existsSync ( outputDir ) ) {
32+ fs . mkdirSync ( outputDir , { recursive : true } ) ;
33+ vscode . window . showInformationMessage ( `c64basicv2.convert: output folder ${ outputDir } created!` ) ;
34+ }
2635 if ( outputDir && fs . existsSync ( outputDir ) ) {
2736 const basePetcatArgs = [
2837 "-w2" ,
Original file line number Diff line number Diff line change @@ -11,7 +11,13 @@ export function run(tokenizedBASICFile: TokenizedBASICFile.TokenizedBASICFile, o
1111 formatter . infoFormatter ( "Run..." , outputChannel ) ;
1212 const command : string | undefined = configuration . get ( "x64sc" ) ;
1313 if ( command && fs . existsSync ( command ) ) {
14- const rootFolder = vscode . workspace . workspaceFolders ? vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath : undefined ;
14+ let rootFolder = vscode . workspace . workspaceFolders ? vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath : undefined ;
15+ if ( ! rootFolder ) {
16+ const workspaceFolders = vscode . workspace . textDocuments . map ( doc => path . dirname ( doc . fileName ) ) ;
17+ if ( workspaceFolders . length > 0 ) {
18+ rootFolder = workspaceFolders [ 0 ] ;
19+ }
20+ }
1521 const baseX64scArgs = [
1622 tokenizedBASICFile . outputFile
1723 ] ;
You can’t perform that action at this time.
0 commit comments