@@ -33,11 +33,11 @@ export async function getSessionList(): Promise<ISession[]> {
33
33
}
34
34
35
35
export async function selectSession ( ) : Promise < void > {
36
- const choice : IQuickItemEx < string > | undefined = await vscode . window . showQuickPick ( parseSessionsToPicks ( ) ) ;
36
+ const choice : IQuickItemEx < string > | undefined = await vscode . window . showQuickPick ( parseSessionsToPicks ( true /* includeOperation */ ) ) ;
37
37
if ( ! choice || choice . description === "Active" ) {
38
38
return ;
39
39
}
40
- if ( choice . value === ":createNewSession " ) {
40
+ if ( choice . value === ":createSession " ) {
41
41
await vscode . commands . executeCommand ( "leetcode.createSession" ) ;
42
42
return ;
43
43
}
@@ -50,7 +50,7 @@ export async function selectSession(): Promise<void> {
50
50
}
51
51
}
52
52
53
- async function parseSessionsToPicks ( ) : Promise < Array < IQuickItemEx < string > > > {
53
+ async function parseSessionsToPicks ( includeOperations : boolean = false ) : Promise < Array < IQuickItemEx < string > > > {
54
54
return new Promise ( async ( resolve : ( res : Array < IQuickItemEx < string > > ) => void ) : Promise < void > => {
55
55
try {
56
56
const sessions : ISession [ ] = await getSessionList ( ) ;
@@ -60,19 +60,31 @@ async function parseSessionsToPicks(): Promise<Array<IQuickItemEx<string>>> {
60
60
detail : `AC Questions: ${ s . acQuestions } , AC Submits: ${ s . acSubmits } ` ,
61
61
value : s . id ,
62
62
} ) ) ;
63
- picks . push ( {
64
- label : "$(plus) Create a new session" ,
65
- description : "" ,
66
- detail : "Click this item to create a new session" ,
67
- value : ":createNewSession" ,
68
- } ) ;
63
+
64
+ if ( includeOperations ) {
65
+ picks . push ( ...parseSessionManagementOperations ( ) ) ;
66
+ }
69
67
resolve ( picks ) ;
70
68
} catch ( error ) {
71
69
return await promptForOpenOutputChannel ( "Failed to list sessions. Please open the output channel for details." , DialogType . error ) ;
72
70
}
73
71
} ) ;
74
72
}
75
73
74
+ function parseSessionManagementOperations ( ) : Array < IQuickItemEx < string > > {
75
+ return [ {
76
+ label : "$(plus) Create a session" ,
77
+ description : "" ,
78
+ detail : "Click this item to create a session" ,
79
+ value : ":createSession" ,
80
+ } , {
81
+ label : "$(trashcan) Delete a session" ,
82
+ description : "" ,
83
+ detail : "Click this item to DELETE a session" ,
84
+ value : ":deleteSession" ,
85
+ } ] ;
86
+ }
87
+
76
88
export async function createSession ( ) : Promise < void > {
77
89
const session : string | undefined = await vscode . window . showInputBox ( {
78
90
prompt : "Enter the new session name." ,
0 commit comments