@@ -6,12 +6,12 @@ import * as vscode from 'vscode';
66// Your extension is activated the very first time the command is executed
77export function activate ( context : vscode . ExtensionContext ) {
88 function getRelativeItemPath ( projectPath : string , fullTargetFilePath : string ) : string | null {
9- var relativeFilePath = fullTargetFilePath . replace ( projectPath , '' ) ;
9+ var relativeFilePath = fullTargetFilePath . replace ( projectPath , '' ) ;
1010 // remove first / or \
11- if ( relativeFilePath [ 0 ] === '/' || relativeFilePath [ 0 ] === '\\' ) {
12- relativeFilePath = relativeFilePath . slice ( 1 , relativeFilePath . length ) ;
11+ if ( relativeFilePath [ 0 ] === '/' || relativeFilePath [ 0 ] === '\\' ) {
12+ relativeFilePath = relativeFilePath . slice ( 1 , relativeFilePath . length ) ;
1313 }
14-
14+
1515 return relativeFilePath ;
1616 }
1717
@@ -24,38 +24,38 @@ export function activate(context: vscode.ExtensionContext) {
2424 return ;
2525 }
2626
27- const fullTargetFilePath : string = commandParam . resourceUri . fsPath ;
28-
27+ const fullTargetFilePath : string = commandParam . resourceUri . fsPath ;
28+
2929 const simpleGit = await import ( 'simple-git' ) ;
3030 if ( vscode . workspace . workspaceFolders ) {
31- // Look through the workspace folders and find the one that has our file.
32- for ( let workspaceFolder of vscode . workspace . workspaceFolders ) {
33- const projectPath = workspaceFolder . uri . fsPath ;
34- if ( fullTargetFilePath . startsWith ( projectPath ) ) {
35- var targetFile = getRelativeItemPath ( projectPath , fullTargetFilePath ) ;
36- if ( targetFile === null ) {
37- vscode . window . showErrorMessage ( 'Could not get target path.' ) ;
38- return ;
39- }
40-
31+ // Look through the workspace folders and find the one that has our file.
32+ for ( let workspaceFolder of vscode . workspace . workspaceFolders ) {
33+ const projectPath = workspaceFolder . uri . fsPath ;
34+ if ( fullTargetFilePath . startsWith ( projectPath ) ) {
35+ var targetFile = getRelativeItemPath ( projectPath , fullTargetFilePath ) ;
36+ if ( targetFile === null ) {
37+ vscode . window . showErrorMessage ( 'Could not get target path.' ) ;
38+ return ;
39+ }
40+
4141 const notifyOnOpen = vscode . workspace . getConfiguration ( 'git-diff-and-merge-tool' ) . get ( 'showNotificationOnOpen' ) ;
4242 if ( notifyOnOpen ) {
4343 vscode . window . showInformationMessage ( infoMessageFunc ( targetFile ) ) ;
4444 }
45-
46- simpleGit ( projectPath ) . raw (
47- gitArgumentsFunc ( targetFile ) ,
48- ( err : any , result : any ) => {
49- if ( err ) {
50- vscode . window . showWarningMessage ( err ) ;
51- }
52- } ) ;
53-
54- return ;
55- }
56- }
5745
58- vscode . window . showErrorMessage ( 'Could not find workspace for ' + fullTargetFilePath ) ;
46+ simpleGit ( projectPath ) . raw (
47+ gitArgumentsFunc ( targetFile ) ,
48+ ( err : any , result : any ) => {
49+ if ( err ) {
50+ vscode . window . showWarningMessage ( err ) ;
51+ }
52+ } ) ;
53+
54+ return ;
55+ }
56+ }
57+
58+ vscode . window . showErrorMessage ( 'Could not find workspace for ' + fullTargetFilePath ) ;
5959 }
6060 }
6161
@@ -78,4 +78,4 @@ export function activate(context: vscode.ExtensionContext) {
7878}
7979
8080// This method is called when your extension is deactivated
81- export function deactivate ( ) { }
81+ export function deactivate ( ) { }
0 commit comments