@@ -6,13 +6,13 @@ import { IQuickItemEx, leetCodeBinaryPath } from "../shared";
6
6
import { executeCommand } from "../utils/cpUtils" ;
7
7
import { DialogType , promptForOpenOutputChannel , promptForSignIn } from "../utils/uiUtils" ;
8
8
9
- export async function getSessionList ( channel : vscode . OutputChannel ) : Promise < ISession [ ] > {
9
+ export async function getSessionList ( ) : Promise < ISession [ ] > {
10
10
const signInStatus : string | undefined = leetCodeManager . getUser ( ) ;
11
11
if ( ! signInStatus ) {
12
12
promptForSignIn ( ) ;
13
13
return [ ] ;
14
14
}
15
- const result : string = await executeCommand ( channel , "node" , [ leetCodeBinaryPath , "session" ] ) ;
15
+ const result : string = await executeCommand ( "node" , [ leetCodeBinaryPath , "session" ] ) ;
16
16
const lines : string [ ] = result . split ( "\n" ) ;
17
17
const sessions : ISession [ ] = [ ] ;
18
18
const reg : RegExp = / ( .? ) \s * ( \d + ) \s + ( .* ) \s + ( \d + \( \s * \d + \. \d + % \) ) \s + ( \d + \( \s * \d + \. \d + % \) ) / ;
@@ -31,8 +31,8 @@ export async function getSessionList(channel: vscode.OutputChannel): Promise<ISe
31
31
return sessions ;
32
32
}
33
33
34
- export async function selectSession ( channel : vscode . OutputChannel ) : Promise < void > {
35
- const choice : IQuickItemEx < string > | undefined = await vscode . window . showQuickPick ( parseSessionsToPicks ( channel ) ) ;
34
+ export async function selectSession ( ) : Promise < void > {
35
+ const choice : IQuickItemEx < string > | undefined = await vscode . window . showQuickPick ( parseSessionsToPicks ( ) ) ;
36
36
if ( ! choice || choice . description === "Active" ) {
37
37
return ;
38
38
}
@@ -41,18 +41,18 @@ export async function selectSession(channel: vscode.OutputChannel): Promise<void
41
41
return ;
42
42
}
43
43
try {
44
- await executeCommand ( channel , "node" , [ leetCodeBinaryPath , "session" , "-e" , choice . value ] ) ;
44
+ await executeCommand ( "node" , [ leetCodeBinaryPath , "session" , "-e" , choice . value ] ) ;
45
45
vscode . window . showInformationMessage ( `Successfully switched to session '${ choice . label } '.` ) ;
46
46
await vscode . commands . executeCommand ( "leetcode.refreshExplorer" ) ;
47
47
} catch ( error ) {
48
- await promptForOpenOutputChannel ( "Failed to switch session. Please open the output channel for details." , DialogType . error , channel ) ;
48
+ await promptForOpenOutputChannel ( "Failed to switch session. Please open the output channel for details." , DialogType . error ) ;
49
49
}
50
50
}
51
51
52
- async function parseSessionsToPicks ( channel : vscode . OutputChannel ) : Promise < Array < IQuickItemEx < string > > > {
52
+ async function parseSessionsToPicks ( ) : Promise < Array < IQuickItemEx < string > > > {
53
53
return new Promise ( async ( resolve : ( res : Array < IQuickItemEx < string > > ) => void ) : Promise < void > => {
54
54
try {
55
- const sessions : ISession [ ] = await getSessionList ( channel ) ;
55
+ const sessions : ISession [ ] = await getSessionList ( ) ;
56
56
const picks : Array < IQuickItemEx < string > > = sessions . map ( ( s : ISession ) => Object . assign ( { } , {
57
57
label : `${ s . active ? "$(check) " : "" } ${ s . name } ` ,
58
58
description : s . active ? "Active" : "" ,
@@ -67,12 +67,12 @@ async function parseSessionsToPicks(channel: vscode.OutputChannel): Promise<Arra
67
67
} ) ;
68
68
resolve ( picks ) ;
69
69
} catch ( error ) {
70
- return await promptForOpenOutputChannel ( "Failed to list sessions. Please open the output channel for details." , DialogType . error , channel ) ;
70
+ return await promptForOpenOutputChannel ( "Failed to list sessions. Please open the output channel for details." , DialogType . error ) ;
71
71
}
72
72
} ) ;
73
73
}
74
74
75
- export async function createSession ( channel : vscode . OutputChannel ) : Promise < void > {
75
+ export async function createSession ( ) : Promise < void > {
76
76
const session : string | undefined = await vscode . window . showInputBox ( {
77
77
prompt : "Enter the new session name." ,
78
78
validateInput : ( s : string ) : string | undefined => s && s . trim ( ) ? undefined : "Session name must not be empty" ,
@@ -81,10 +81,10 @@ export async function createSession(channel: vscode.OutputChannel): Promise<void
81
81
return ;
82
82
}
83
83
try {
84
- await executeCommand ( channel , "node" , [ leetCodeBinaryPath , "session" , "-c" , session ] ) ;
84
+ await executeCommand ( "node" , [ leetCodeBinaryPath , "session" , "-c" , session ] ) ;
85
85
vscode . window . showInformationMessage ( "New session created, you can switch to it by clicking the status bar." ) ;
86
86
} catch ( error ) {
87
- await promptForOpenOutputChannel ( "Failed to create session. Please open the output channel for details." , DialogType . error , channel ) ;
87
+ await promptForOpenOutputChannel ( "Failed to create session. Please open the output channel for details." , DialogType . error ) ;
88
88
}
89
89
}
90
90
0 commit comments