@@ -34,6 +34,7 @@ import {
3434 StatusFileNode ,
3535 TagNode ,
3636 ViewNode ,
37+ ViewRefFileNode ,
3738 ViewRefNode ,
3839 viewSupportsNodeDismissal
3940} from './nodes' ;
@@ -210,10 +211,8 @@ export class ViewCommands implements Disposable {
210211 return node . push ( { force : force } ) ;
211212 }
212213
213- private async applyChanges ( node : CommitFileNode | StashFileNode | ResultsFileNode ) {
214- if ( ! ( node instanceof CommitFileNode ) && ! ( node instanceof ResultsFileNode ) ) {
215- return ;
216- }
214+ private async applyChanges ( node : ViewRefFileNode ) {
215+ if ( ! ( node instanceof ViewRefFileNode ) ) return ;
217216
218217 void ( await this . openFile ( node ) ) ;
219218
@@ -228,9 +227,13 @@ export class ViewCommands implements Disposable {
228227 }
229228 }
230229
231- private checkout ( node : ViewRefNode ) {
230+ private checkout ( node : ViewRefNode | ViewRefFileNode ) {
232231 if ( ! ( node instanceof ViewRefNode ) ) return undefined ;
233232
233+ if ( node instanceof ViewRefFileNode ) {
234+ return Container . git . checkout ( node . repoPath , node . ref , node . fileName ) ;
235+ }
236+
234237 return Container . git . checkout ( node . repoPath , node . ref ) ;
235238 }
236239
@@ -287,14 +290,11 @@ export class ViewCommands implements Disposable {
287290 Container . compareView . selectForCompare ( node . repoPath , node . ref ) ;
288291 }
289292
290- private compareFileWithSelected ( node : CommitFileNode | ResultsFileNode | StashFileNode ) {
291- if (
292- this . _selectedFile === undefined ||
293- ( ! ( node instanceof CommitFileNode ) && ! ( node instanceof ResultsFileNode ) ) ||
294- node . ref === undefined
295- ) {
293+ private compareFileWithSelected ( node : ViewRefFileNode ) {
294+ if ( this . _selectedFile === undefined || ! ( node instanceof ViewRefFileNode ) || node . ref === undefined ) {
296295 return undefined ;
297296 }
297+
298298 if ( this . _selectedFile . repoPath !== node . repoPath ) {
299299 this . selectFileForCompare ( node ) ;
300300 return undefined ;
@@ -321,8 +321,8 @@ export class ViewCommands implements Disposable {
321321
322322 private _selectedFile : CompareSelectedInfo | undefined ;
323323
324- private selectFileForCompare ( node : CommitFileNode | ResultsFileNode | StashFileNode ) {
325- if ( ( ! ( node instanceof CommitFileNode ) && ! ( node instanceof ResultsFileNode ) ) || node . ref === undefined ) return ;
324+ private selectFileForCompare ( node : ViewRefFileNode ) {
325+ if ( ! ( node instanceof ViewRefFileNode ) || node . ref === undefined ) return ;
326326
327327 this . _selectedFile = {
328328 ref : node . ref ,
@@ -343,8 +343,8 @@ export class ViewCommands implements Disposable {
343343 void commands . executeCommand ( BuiltInCommands . FocusFilesExplorer ) ;
344344 }
345345
346- private openChanges ( node : CommitFileNode | ResultsFileNode | StashFileNode ) {
347- if ( ! ( node instanceof CommitFileNode ) && ! ( node instanceof ResultsFileNode ) ) return undefined ;
346+ private openChanges ( node : ViewRefFileNode ) {
347+ if ( ! ( node instanceof ViewRefFileNode ) ) return undefined ;
348348
349349 const command = node . getCommand ( ) ;
350350 if ( command === undefined || command . arguments === undefined ) return undefined ;
@@ -354,8 +354,8 @@ export class ViewCommands implements Disposable {
354354 return commands . executeCommand ( command . command , uri , args ) ;
355355 }
356356
357- private async openChangesWithWorking ( node : CommitFileNode | ResultsFileNode | StashFileNode ) {
358- if ( ! ( node instanceof CommitFileNode ) && ! ( node instanceof ResultsFileNode ) ) return undefined ;
357+ private async openChangesWithWorking ( node : ViewRefFileNode ) {
358+ if ( ! ( node instanceof ViewRefFileNode ) ) return undefined ;
359359
360360 const args : DiffWithWorkingCommandArgs = {
361361 showOptions : {
@@ -375,15 +375,12 @@ export class ViewCommands implements Disposable {
375375 return commands . executeCommand ( Commands . DiffWithWorking , node . uri , args ) ;
376376 }
377377
378- private openFile (
379- node : CommitFileNode | FileHistoryNode | LineHistoryNode | ResultsFileNode | StashFileNode | StatusFileNode
380- ) {
378+ private openFile ( node : ViewRefFileNode | StatusFileNode | FileHistoryNode | LineHistoryNode ) {
381379 if (
382- ! ( node instanceof CommitFileNode ) &&
380+ ! ( node instanceof ViewRefFileNode ) &&
381+ ! ( node instanceof StatusFileNode ) &&
383382 ! ( node instanceof FileHistoryNode ) &&
384- ! ( node instanceof LineHistoryNode ) &&
385- ! ( node instanceof ResultsFileNode ) &&
386- ! ( node instanceof StatusFileNode )
383+ ! ( node instanceof LineHistoryNode )
387384 ) {
388385 return undefined ;
389386 }
0 commit comments