@@ -30,7 +30,7 @@ import { filterMap, find, first, join, map } from '../system/iterable';
30
30
import { getLoggableName , Logger } from '../system/logger' ;
31
31
import { startLogScope } from '../system/logger.scope' ;
32
32
import { pluralize } from '../system/string' ;
33
- import { asCommand , executeCoreCommand } from '../system/vscode/command' ;
33
+ import { createCommand , executeCoreCommand } from '../system/vscode/command' ;
34
34
import { configuration } from '../system/vscode/configuration' ;
35
35
import { isVirtualUri } from '../system/vscode/utils' ;
36
36
@@ -610,17 +610,15 @@ function applyDiffWithPreviousCommand<T extends GitRecentChangeCodeLens | GitAut
610
610
lens : T ,
611
611
commit : GitCommit | undefined ,
612
612
) : T {
613
- lens . command = asCommand < [ undefined , DiffWithPreviousCommandArgs ] > ( {
614
- title : title ,
615
- command : Commands . DiffWithPrevious ,
616
- arguments : [
617
- undefined ,
618
- {
619
- commit : commit ,
620
- uri : lens . uri ! . toFileUri ( ) ,
621
- } ,
622
- ] ,
623
- } ) ;
613
+ lens . command = createCommand < [ undefined , DiffWithPreviousCommandArgs ] > (
614
+ Commands . DiffWithPrevious ,
615
+ title ,
616
+ undefined ,
617
+ {
618
+ commit : commit ,
619
+ uri : lens . uri ! . toFileUri ( ) ,
620
+ } ,
621
+ ) ;
624
622
return lens ;
625
623
}
626
624
@@ -630,19 +628,13 @@ function applyCopyOrOpenCommitOnRemoteCommand<T extends GitRecentChangeCodeLens
630
628
commit : GitCommit ,
631
629
clipboard : boolean = false ,
632
630
) : T {
633
- lens . command = asCommand < [ OpenOnRemoteCommandArgs ] > ( {
634
- title : title ,
635
- command : Commands . OpenOnRemote ,
636
- arguments : [
637
- {
638
- resource : {
639
- type : RemoteResourceType . Commit ,
640
- sha : commit . sha ,
641
- } ,
642
- repoPath : commit . repoPath ,
643
- clipboard : clipboard ,
644
- } ,
645
- ] ,
631
+ lens . command = createCommand < [ OpenOnRemoteCommandArgs ] > ( Commands . OpenOnRemote , title , {
632
+ resource : {
633
+ type : RemoteResourceType . Commit ,
634
+ sha : commit . sha ,
635
+ } ,
636
+ repoPath : commit . repoPath ,
637
+ clipboard : clipboard ,
646
638
} ) ;
647
639
return lens ;
648
640
}
@@ -653,20 +645,14 @@ function applyCopyOrOpenFileOnRemoteCommand<T extends GitRecentChangeCodeLens |
653
645
commit : GitCommit ,
654
646
clipboard : boolean = false ,
655
647
) : T {
656
- lens . command = asCommand < [ OpenOnRemoteCommandArgs ] > ( {
657
- title : title ,
658
- command : Commands . OpenOnRemote ,
659
- arguments : [
660
- {
661
- resource : {
662
- type : RemoteResourceType . Revision ,
663
- fileName : commit . file ?. path ?? '' ,
664
- sha : commit . sha ,
665
- } ,
666
- repoPath : commit . repoPath ,
667
- clipboard : clipboard ,
668
- } ,
669
- ] ,
648
+ lens . command = createCommand < [ OpenOnRemoteCommandArgs ] > ( Commands . OpenOnRemote , title , {
649
+ resource : {
650
+ type : RemoteResourceType . Revision ,
651
+ fileName : commit . file ?. path ?? '' ,
652
+ sha : commit . sha ,
653
+ } ,
654
+ repoPath : commit . repoPath ,
655
+ clipboard : clipboard ,
670
656
} ) ;
671
657
return lens ;
672
658
}
@@ -676,17 +662,15 @@ function applyRevealCommitInViewCommand<T extends GitRecentChangeCodeLens | GitA
676
662
lens : T ,
677
663
commit : GitCommit | undefined ,
678
664
) : T {
679
- lens . command = asCommand < [ Uri , ShowQuickCommitCommandArgs ] > ( {
680
- title : title ,
681
- command : commit ?. isUncommitted ? '' : CodeLensCommand . RevealCommitInView ,
682
- arguments : [
683
- lens . uri ! . toFileUri ( ) ,
684
- {
685
- commit : commit ,
686
- sha : commit === undefined ? undefined : commit . sha ,
687
- } ,
688
- ] ,
689
- } ) ;
665
+ lens . command = createCommand < [ Uri , ShowQuickCommitCommandArgs ] > (
666
+ commit ?. isUncommitted ? ( '' as CodeLensCommand ) : CodeLensCommand . RevealCommitInView ,
667
+ title ,
668
+ lens . uri ! . toFileUri ( ) ,
669
+ {
670
+ commit : commit ,
671
+ sha : commit === undefined ? undefined : commit . sha ,
672
+ } ,
673
+ ) ;
690
674
return lens ;
691
675
}
692
676
@@ -703,16 +687,14 @@ function applyShowCommitsInViewCommand<T extends GitRecentChangeCodeLens | GitAu
703
687
refs = [ commit . ref ] ;
704
688
}
705
689
706
- lens . command = asCommand < [ ShowCommitsInViewCommandArgs ] > ( {
707
- title : title ,
708
- command : refs . length === 0 ? '' : Commands . ShowCommitsInView ,
709
- arguments : [
710
- {
711
- repoPath : blame . repoPath ,
712
- refs : refs ,
713
- } ,
714
- ] ,
715
- } ) ;
690
+ lens . command = createCommand < [ ShowCommitsInViewCommandArgs ] > (
691
+ refs . length === 0 ? ( '' as Commands ) : Commands . ShowCommitsInView ,
692
+ title ,
693
+ {
694
+ repoPath : blame . repoPath ,
695
+ refs : refs ,
696
+ } ,
697
+ ) ;
716
698
return lens ;
717
699
}
718
700
@@ -721,17 +703,15 @@ function applyShowQuickCommitDetailsCommand<T extends GitRecentChangeCodeLens |
721
703
lens : T ,
722
704
commit : GitCommit | undefined ,
723
705
) : T {
724
- lens . command = asCommand < [ Uri , ShowQuickCommitCommandArgs ] > ( {
725
- title : title ,
726
- command : commit ?. isUncommitted ? '' : CodeLensCommand . ShowQuickCommitDetails ,
727
- arguments : [
728
- lens . uri ! . toFileUri ( ) ,
729
- {
730
- commit : commit ,
731
- sha : commit === undefined ? undefined : commit . sha ,
732
- } ,
733
- ] ,
734
- } ) ;
706
+ lens . command = createCommand < [ Uri , ShowQuickCommitCommandArgs ] > (
707
+ commit ?. isUncommitted ? ( '' as CodeLensCommand ) : CodeLensCommand . ShowQuickCommitDetails ,
708
+ title ,
709
+ lens . uri ! . toFileUri ( ) ,
710
+ {
711
+ commit : commit ,
712
+ sha : commit === undefined ? undefined : commit . sha ,
713
+ } ,
714
+ ) ;
735
715
return lens ;
736
716
}
737
717
@@ -740,58 +720,46 @@ function applyShowQuickCommitFileDetailsCommand<T extends GitRecentChangeCodeLen
740
720
lens : T ,
741
721
commit : GitCommit | undefined ,
742
722
) : T {
743
- lens . command = asCommand < [ Uri , ShowQuickCommitFileCommandArgs ] > ( {
744
- title : title ,
745
- command : commit ?. isUncommitted ? '' : CodeLensCommand . ShowQuickCommitFileDetails ,
746
- arguments : [
747
- lens . uri ! . toFileUri ( ) ,
748
- {
749
- commit : commit ,
750
- sha : commit === undefined ? undefined : commit . sha ,
751
- } ,
752
- ] ,
753
- } ) ;
723
+ lens . command = createCommand < [ Uri , ShowQuickCommitFileCommandArgs ] > (
724
+ commit ?. isUncommitted ? ( '' as CodeLensCommand ) : CodeLensCommand . ShowQuickCommitFileDetails ,
725
+ title ,
726
+ lens . uri ! . toFileUri ( ) ,
727
+ {
728
+ commit : commit ,
729
+ sha : commit === undefined ? undefined : commit . sha ,
730
+ } ,
731
+ ) ;
754
732
return lens ;
755
733
}
756
734
757
735
function applyShowQuickCurrentBranchHistoryCommand < T extends GitRecentChangeCodeLens | GitAuthorsCodeLens > (
758
736
title : string ,
759
737
lens : T ,
760
738
) : T {
761
- lens . command = asCommand < [ Uri ] > ( {
762
- title : title ,
763
- command : CodeLensCommand . ShowQuickCurrentBranchHistory ,
764
- arguments : [ lens . uri ! . toFileUri ( ) ] ,
765
- } ) ;
739
+ lens . command = createCommand < [ Uri ] > ( CodeLensCommand . ShowQuickCurrentBranchHistory , title , lens . uri ! . toFileUri ( ) ) ;
766
740
return lens ;
767
741
}
768
742
769
743
function applyShowQuickFileHistoryCommand < T extends GitRecentChangeCodeLens | GitAuthorsCodeLens > (
770
744
title : string ,
771
745
lens : T ,
772
746
) : T {
773
- lens . command = asCommand < [ Uri , ShowQuickFileHistoryCommandArgs ] > ( {
774
- title : title ,
775
- command : CodeLensCommand . ShowQuickFileHistory ,
776
- arguments : [
777
- lens . uri ! . toFileUri ( ) ,
778
- {
779
- range : lens . isFullRange ? undefined : lens . blameRange ,
780
- } ,
781
- ] ,
782
- } ) ;
747
+ lens . command = createCommand < [ Uri , ShowQuickFileHistoryCommandArgs ] > (
748
+ CodeLensCommand . ShowQuickFileHistory ,
749
+ title ,
750
+ lens . uri ! . toFileUri ( ) ,
751
+ {
752
+ range : lens . isFullRange ? undefined : lens . blameRange ,
753
+ } ,
754
+ ) ;
783
755
return lens ;
784
756
}
785
757
786
758
function applyToggleFileBlameCommand < T extends GitRecentChangeCodeLens | GitAuthorsCodeLens > (
787
759
title : string ,
788
760
lens : T ,
789
761
) : T {
790
- lens . command = asCommand < [ Uri ] > ( {
791
- title : title ,
792
- command : Commands . ToggleFileBlame ,
793
- arguments : [ lens . uri ! . toFileUri ( ) ] ,
794
- } ) ;
762
+ lens . command = createCommand < [ Uri ] > ( Commands . ToggleFileBlame , title , lens . uri ! . toFileUri ( ) ) ;
795
763
return lens ;
796
764
}
797
765
@@ -801,29 +769,23 @@ function applyToggleFileChangesCommand<T extends GitRecentChangeCodeLens | GitAu
801
769
commit : GitCommit ,
802
770
only ?: boolean ,
803
771
) : T {
804
- lens . command = asCommand < [ Uri , ToggleFileChangesAnnotationCommandArgs ] > ( {
805
- title : title ,
806
- command : Commands . ToggleFileChanges ,
807
- arguments : [
808
- lens . uri ! . toFileUri ( ) ,
809
- {
810
- type : 'changes' ,
811
- context : { sha : commit . sha , only : only , selection : false } ,
812
- } ,
813
- ] ,
814
- } ) ;
772
+ lens . command = createCommand < [ Uri , ToggleFileChangesAnnotationCommandArgs ] > (
773
+ Commands . ToggleFileChanges ,
774
+ title ,
775
+ lens . uri ! . toFileUri ( ) ,
776
+ {
777
+ type : 'changes' ,
778
+ context : { sha : commit . sha , only : only , selection : false } ,
779
+ } ,
780
+ ) ;
815
781
return lens ;
816
782
}
817
783
818
784
function applyToggleFileHeatmapCommand < T extends GitRecentChangeCodeLens | GitAuthorsCodeLens > (
819
785
title : string ,
820
786
lens : T ,
821
787
) : T {
822
- lens . command = asCommand < [ Uri ] > ( {
823
- title : title ,
824
- command : Commands . ToggleFileHeatmap ,
825
- arguments : [ lens . uri ! . toFileUri ( ) ] ,
826
- } ) ;
788
+ lens . command = createCommand < [ Uri ] > ( Commands . ToggleFileHeatmap , title , lens . uri ! . toFileUri ( ) ) ;
827
789
return lens ;
828
790
}
829
791
0 commit comments