@@ -588,6 +588,18 @@ export abstract class CommonTask {
588588 return undefined ;
589589 }
590590
591+ protected abstract getFolderId ( ) : string | undefined ;
592+
593+ public getCommonTaskId ( ) : string {
594+ interface RecentTaskKey {
595+ folder : string | undefined ;
596+ id : string ;
597+ }
598+
599+ const key : RecentTaskKey = { folder : this . getFolderId ( ) , id : this . _id } ;
600+ return JSON . stringify ( key ) ;
601+ }
602+
591603 public clone ( ) : Task {
592604 return this . fromObject ( Objects . assign ( { } , < any > this ) ) ;
593605 }
@@ -728,13 +740,21 @@ export class CustomTask extends CommonTask {
728740 return workspaceFolder ? `${ workspaceFolder . uri . toString ( ) } |${ this . _id } |${ this . instance } ` : `${ this . _id } |${ this . instance } ` ;
729741 }
730742
743+ protected getFolderId ( ) : string | undefined {
744+ return this . _source . kind === TaskSourceKind . User ? USER_TASKS_GROUP_KEY : this . _source . config . workspaceFolder ?. uri . toString ( ) ;
745+ }
746+
747+ public getCommonTaskId ( ) : string {
748+ return this . _source . customizes ? super . getCommonTaskId ( ) : ( this . getRecentlyUsedKey ( ) ?? super . getCommonTaskId ( ) ) ;
749+ }
750+
731751 public getRecentlyUsedKey ( ) : string | undefined {
732752 interface CustomKey {
733753 type : string ;
734754 folder : string ;
735755 id : string ;
736756 }
737- let workspaceFolder = this . _source . kind === TaskSourceKind . User ? USER_TASKS_GROUP_KEY : this . _source . config . workspaceFolder ?. uri . toString ( ) ;
757+ let workspaceFolder = this . getFolderId ( ) ;
738758 if ( ! workspaceFolder ) {
739759 return undefined ;
740760 }
@@ -803,13 +823,17 @@ export class ConfiguringTask extends CommonTask {
803823 return this . _source . config . workspaceFolder ;
804824 }
805825
826+ protected getFolderId ( ) : string | undefined {
827+ return this . _source . kind === TaskSourceKind . User ? USER_TASKS_GROUP_KEY : this . _source . config . workspaceFolder ?. uri . toString ( ) ;
828+ }
829+
806830 public getRecentlyUsedKey ( ) : string | undefined {
807831 interface CustomKey {
808832 type : string ;
809833 folder : string ;
810834 id : string ;
811835 }
812- let workspaceFolder = this . _source . kind === TaskSourceKind . User ? USER_TASKS_GROUP_KEY : this . _source . config . workspaceFolder ?. uri . toString ( ) ;
836+ let workspaceFolder = this . getFolderId ( ) ;
813837 if ( ! workspaceFolder ) {
814838 return undefined ;
815839 }
@@ -865,6 +889,13 @@ export class ContributedTask extends CommonTask {
865889 : `${ this . _source . scope . toString ( ) } |${ this . _id } |${ this . instance } ` ;
866890 }
867891
892+ protected getFolderId ( ) : string | undefined {
893+ if ( this . _source . scope === TaskScope . Folder && this . _source . workspaceFolder ) {
894+ return this . _source . workspaceFolder . uri . toString ( ) ;
895+ }
896+ return undefined ;
897+ }
898+
868899 public getRecentlyUsedKey ( ) : string | undefined {
869900 interface ContributedKey {
870901 type : string ;
@@ -874,9 +905,7 @@ export class ContributedTask extends CommonTask {
874905 }
875906
876907 let key : ContributedKey = { type : 'contributed' , scope : this . _source . scope , id : this . _id } ;
877- if ( this . _source . scope === TaskScope . Folder && this . _source . workspaceFolder ) {
878- key . folder = this . _source . workspaceFolder . uri . toString ( ) ;
879- }
908+ key . folder = this . getFolderId ( ) ;
880909 return JSON . stringify ( key ) ;
881910 }
882911
@@ -921,6 +950,10 @@ export class InMemoryTask extends CommonTask {
921950 return `${ this . _id } |${ this . instance } ` ;
922951 }
923952
953+ protected getFolderId ( ) : undefined {
954+ return undefined ;
955+ }
956+
924957 protected fromObject ( object : InMemoryTask ) : InMemoryTask {
925958 return new InMemoryTask ( object . _id , object . _source , object . _label , object . type , object . runOptions , object . configurationProperties ) ;
926959 }
0 commit comments