Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbc2caa1

Browse files
authored
fix session switch bug (LeetCode-OpenSource#13)
* fix session switch bug* refine code
1 parent8ea762c commitbc2caa1

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

‎src/commands/session.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function getSessionList(channel: vscode.OutputChannel): Promise<ISe
3232
}
3333

3434
exportasyncfunctionselectSession(channel:vscode.OutputChannel):Promise<void>{
35-
constchoice:IQuickItemEx<string>|undefined=awaitvscode.window.showQuickPick(parseSessionsToPicks(getSessionList(channel)));
35+
constchoice:IQuickItemEx<string>|undefined=awaitvscode.window.showQuickPick(parseSessionsToPicks(channel));
3636
if(!choice||choice.description==="Active"){
3737
return;
3838
}
@@ -49,21 +49,26 @@ export async function selectSession(channel: vscode.OutputChannel): Promise<void
4949
}
5050
}
5151

52-
asyncfunctionparseSessionsToPicks(p:Promise<ISession[]>):Promise<Array<IQuickItemEx<string>>>{
52+
asyncfunctionparseSessionsToPicks(channel:vscode.OutputChannel):Promise<Array<IQuickItemEx<string>>>{
5353
returnnewPromise(async(resolve:(res:Array<IQuickItemEx<string>>)=>void):Promise<void>=>{
54-
constpicks:Array<IQuickItemEx<string>>=(awaitp).map((s:ISession)=>Object.assign({},{
55-
label:`${s.active ?"$(check) " :""}${s.name}`,
56-
description:s.active ?"Active" :"",
57-
detail:`AC Questions:${s.acQuestions}, AC Submits:${s.acSubmits}`,
58-
value:s.id,
59-
}));
60-
picks.push({
61-
label:"$(plus) Create a new session",
62-
description:"",
63-
detail:"Click this item to create a new session",
64-
value:":createNewSession",
65-
});
66-
resolve(picks);
54+
try{
55+
constsessions:ISession[]=awaitgetSessionList(channel);
56+
constpicks:Array<IQuickItemEx<string>>=sessions.map((s:ISession)=>Object.assign({},{
57+
label:`${s.active ?"$(check) " :""}${s.name}`,
58+
description:s.active ?"Active" :"",
59+
detail:`AC Questions:${s.acQuestions}, AC Submits:${s.acSubmits}`,
60+
value:s.id,
61+
}));
62+
picks.push({
63+
label:"$(plus) Create a new session",
64+
description:"",
65+
detail:"Click this item to create a new session",
66+
value:":createNewSession",
67+
});
68+
resolve(picks);
69+
}catch(error){
70+
returnawaitpromptForOpenOutputChannel("Failed to list sessions. Please open the output channel for details",DialogType.error,channel);
71+
}
6772
});
6873
}
6974

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp