@@ -14,7 +14,6 @@ import { actionResultStatus, ApplicationConstants, ProjectInfoService } from '..
1414import FileImportCommon from './FileImportCommon' ;
1515
1616export default class CompareFile extends FileImportCommon {
17- private static readonly ACCOUNT_COPY_BASE_NAME = 'accountCopy' ;
1817 private static readonly COMMAND_NAME = 'comparefile' ;
1918 private static readonly SCHEME = 'suitecloud' ;
2019 private static readonly TEMP_FOLDER_PREFIX = 'suitecloud-vscode-extension-compare-file-' ;
@@ -47,25 +46,26 @@ export default class CompareFile extends FileImportCommon {
4746
4847 protected async execute ( ) {
4948 const activeFilePath = this . activeFile ! ;
50- const tempFolderPath = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , CompareFile . TEMP_FOLDER_PREFIX ) ) ;
51-
52- this . copyManifestFileToTempFolder ( tempFolderPath ) ;
53- this . copyProjectJsonToTempFolder ( tempFolderPath ) ;
49+ // create temp project folder to import file to be compared
50+ const tempProjectFolderPath = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , CompareFile . TEMP_FOLDER_PREFIX ) ) ;
51+ // temp project prepartion to import file
52+ this . copyManifestFileToTempFolder ( tempProjectFolderPath ) ;
53+ this . copyProjectJsonToTempFolder ( tempProjectFolderPath ) ;
5454 const activeFileRelativePath = activeFilePath . split ( this . getFileCabinetFolderPath ( ) ) [ 1 ] ?. replace ( / \\ / g, '/' ) ;
55- const importFilePath = this . getImportFilePath ( tempFolderPath , activeFilePath , activeFileRelativePath ) ;
56-
57- const selectedFilesPaths = [ ] ;
58- selectedFilesPaths . push ( activeFileRelativePath ) ;
55+ const importFilePath = this . getImportFilePath ( tempProjectFolderPath , activeFilePath , activeFileRelativePath ) ;
5956
60- const commandArgs = {
61- paths : selectedFilesPaths ,
57+ // file:import args preparation and trigger
58+ const fileImportArgs = {
59+ paths : [ activeFileRelativePath ] ,
6260 excludeproperties : 'true' ,
6361 calledfromcomparefiles : 'true' ,
6462 } ;
65-
66- const commandActionPromise = this . runSuiteCloudCommand ( commandArgs , tempFolderPath ) ;
63+ const commandActionPromise = this . runSuiteCloudCommand ( fileImportArgs , tempProjectFolderPath ) ;
6764 this . messageService . showStatusBarMessage ( this . translationService . getMessage ( COMPARE_FILE . COMPARING_FILE ) , true , commandActionPromise ) ;
65+
66+ // file:import result
6867 const actionResult = await commandActionPromise ;
68+
6969 if ( actionResult . status === actionResultStatus . SUCCESS && actionResult . data ) {
7070 if ( actionResult . data . results [ 0 ] . loaded ) {
7171 vscode . commands . executeCommand (
@@ -89,14 +89,13 @@ export default class CompareFile extends FileImportCommon {
8989
9090 private getImportedFileUri ( importFilePath : string ) : Uri {
9191 const scheme = CompareFile . SCHEME ;
92- const provider = new ( class implements vscode . TextDocumentContentProvider {
92+ const provider = new class implements vscode . TextDocumentContentProvider {
9393 provideTextDocumentContent ( uri : vscode . Uri ) : string {
94- return fs . readFileSync ( importFilePath , 'utf-8' ) ;
94+ return fs . readFileSync ( uri . fsPath , 'utf-8' ) ;
9595 }
96- } ) ( ) ;
96+ } ;
9797 vscode . workspace . registerTextDocumentContentProvider ( scheme , provider ) ;
98- const accountCopyExtension = path . extname ( importFilePath ) ;
99- const schemeUri = `${ scheme } : ${ CompareFile . ACCOUNT_COPY_BASE_NAME } .${ accountCopyExtension } ` ;
98+ const schemeUri = `${ scheme } :${ importFilePath } ` ;
10099 return vscode . Uri . parse ( schemeUri ) ;
101100 }
102101
0 commit comments