@@ -81,8 +81,8 @@ export class SvnCommands {
8181 options : { repository : true }
8282 } ,
8383 {
84- commandId : "svn.openChanges " ,
85- method : this . openChanges ,
84+ commandId : "svn.openDiffHead " ,
85+ method : this . openDiffHead ,
8686 options : { }
8787 } ,
8888 {
@@ -212,55 +212,40 @@ export class SvnCommands {
212212 repository . update ( ) ;
213213 }
214214
215- async openChanges ( resource : Resource ) {
216- if ( resource instanceof Resource ) {
217- this . openResource ( resource , true ) ;
218- }
219- }
220-
221- private async openResource (
222- resource : Resource ,
223- preview ?: boolean ,
224- preserveFocus ?: boolean ,
225- preserveSelection ?: boolean
226- ) {
215+ async openDiff ( resource : Resource , against : string ) {
227216 const left = this . getLeftResource ( resource ) ;
228217 const right = this . getRightResource ( resource ) ;
229- // const title = this.getTitle(resource);
230- const title = "test" ;
218+ const title = this . getDiffTitle ( resource , against ) ;
231219
232220 if ( ! right ) {
233221 return ;
234222 }
235223
236224 if ( ! left ) {
237- window . showErrorMessage ( "File not found on HEAD" ) ;
225+ window . showErrorMessage ( `No diff available at ${ against } ` ) ;
238226 return ;
239227 }
240228
241- const options : TextDocumentShowOptions = {
242- preserveFocus,
243- preview
244- } ;
229+ try {
230+ await commands . executeCommand ( "vscode.diff" , left , right , title ) ;
231+ } catch ( error ) {
232+ console . log ( error ) ;
233+ }
234+ }
245235
246- const activeTextEditor = window . activeTextEditor ;
236+ private getDiffTitle ( resource : Resource , ref : string ) : string {
237+ let file = path . basename ( resource . relativePath ) ;
247238
248- if (
249- preserveSelection &&
250- activeTextEditor &&
251- activeTextEditor . document . uri . path === right . path
252- ) {
253- options . selection = activeTextEditor . selection ;
254- }
239+ return `${ file } (${ ref } )` ;
240+ }
255241
256- if ( ! preview ) {
257- await commands . executeCommand ( "vscode.open" , right ) ;
258- } else {
259- await commands . executeCommand ( "vscode.diff" , left , right , title ) ;
242+ async openDiffHead ( resource : Resource ) {
243+ if ( resource instanceof Resource ) {
244+ this . openDiff ( resource , "HEAD" ) ;
260245 }
261246 }
262247
263- private async getURI ( uri : Uri , ref : string ) {
248+ private getURI ( uri : Uri , ref : string ) : Uri {
264249 return toSvnUri ( uri , ref ) ;
265250 }
266251
@@ -273,7 +258,7 @@ export class SvnCommands {
273258
274259 switch ( resource . type ) {
275260 case "modified" :
276- return this . getURI ( resource . resourceUri , "~ " ) ;
261+ return this . getURI ( resource . resourceUri , "HEAD " ) ;
277262 default :
278263 return false ;
279264 }
0 commit comments