@@ -77,6 +77,43 @@ export async function searchProblem(): Promise<void> {
7777 await showProblemInternal ( choice . value ) ;
7878}
7979
80+ export async function getProblemByIds ( ) : Promise < void > {
81+ if ( ! leetCodeManager . getUser ( ) ) {
82+ promptForSignIn ( ) ;
83+ return ;
84+ }
85+
86+ const ids : string | undefined = await vscode . window . showInputBox ( {
87+ prompt : "Input problem ids ,such as [1,2,3]" ,
88+ ignoreFocusOut : true ,
89+ validateInput : ( s : string ) : string | undefined => s && s . trim ( ) ? undefined : "The input must not be empty" ,
90+ } ) ;
91+
92+ try {
93+ let res :any = JSON . parse ( ids || "" ) ;
94+ if ( ! Array . isArray ( res ) ) {
95+ vscode . window . showErrorMessage ( "The problem ids should be array" ) ;
96+ return ;
97+ }
98+ if ( res . length === 0 ) {
99+ vscode . window . showErrorMessage ( "The problem ids must not be empty" ) ;
100+ return ;
101+ }
102+ res = res . map ( v => String ( v ) ) ;
103+ const allProblems : any = await list . listProblems ( ) ;
104+ const problems : any = allProblems . filter ( v => res . includes ( v . id ) || res . includes ( v . name ) ) ;
105+ if ( ! problems . length ) {
106+ return ;
107+ }
108+ while ( problems . length !== 0 ) {
109+ const cur = problems . shift ( ) ;
110+ await showProblemInternal ( cur , true ) ;
111+ }
112+ } catch ( error ) {
113+ vscode . window . showErrorMessage ( error )
114+ }
115+ }
116+
80117export async function showSolution ( input : LeetCodeNode | vscode . Uri ) : Promise < void > {
81118 let problemInput : string | undefined ;
82119 if ( input instanceof LeetCodeNode ) { // Triggerred from explorer
@@ -131,7 +168,7 @@ async function fetchProblemLanguage(): Promise<string | undefined> {
131168 return language ;
132169}
133170
134- async function showProblemInternal ( node : IProblem ) : Promise < void > {
171+ async function showProblemInternal ( node : IProblem , muteFlag : boolean = false ) : Promise < void > {
135172 try {
136173 const language : string | undefined = await fetchProblemLanguage ( ) ;
137174 if ( ! language ) {
@@ -168,6 +205,10 @@ async function showProblemInternal(node: IProblem): Promise<void> {
168205
169206 const descriptionConfig : IDescriptionConfiguration = settingUtils . getDescriptionConfiguration ( ) ;
170207 await leetCodeExecutor . showProblem ( node , language , finalPath , descriptionConfig . showInComment ) ;
208+ if ( muteFlag ) {
209+ vscode . window . showInformationMessage ( `Added ${ node . id } .${ node . name } !` ) ;
210+ return ;
211+ }
171212 const promises : any [ ] = [
172213 vscode . window . showTextDocument ( vscode . Uri . file ( finalPath ) , { preview : false , viewColumn : vscode . ViewColumn . One } ) ,
173214 promptHintMessage (
0 commit comments