@@ -77,6 +77,41 @@ 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+ const ids : string | undefined = await vscode . window . showInputBox ( {
86+ prompt : "Input problem ids ,such as [1,2,3]" ,
87+ ignoreFocusOut : true ,
88+ validateInput : ( s : string ) : string | undefined => s && s . trim ( ) ? undefined : "The input must not be empty" ,
89+ } ) ;
90+ try {
91+ let res : any = JSON . parse ( ids || "" ) ;
92+ if ( ! Array . isArray ( res ) ) {
93+ vscode . window . showErrorMessage ( "The problem ids should be array" ) ;
94+ return ;
95+ }
96+ if ( res . length === 0 ) {
97+ vscode . window . showErrorMessage ( "The problem ids must not be empty" ) ;
98+ return ;
99+ }
100+ res = res . map ( ( v : any ) => String ( v ) ) ;
101+ const allProblems : any = await list . listProblems ( ) ;
102+ const problems : any = allProblems . filter ( ( v : IProblem ) => res . includes ( v . id ) || res . includes ( v . name ) ) ;
103+ if ( ! problems . length ) {
104+ return ;
105+ }
106+ while ( problems . length !== 0 ) {
107+ const cur : IProblem = problems . shift ( ) ;
108+ await showProblemInternal ( cur , true ) ;
109+ }
110+ } catch ( error ) {
111+ vscode . window . showErrorMessage ( error ) ;
112+ }
113+ }
114+
80115export async function showSolution ( input : LeetCodeNode | vscode . Uri ) : Promise < void > {
81116 let problemInput : string | undefined ;
82117 if ( input instanceof LeetCodeNode ) { // Triggerred from explorer
@@ -131,7 +166,7 @@ async function fetchProblemLanguage(): Promise<string | undefined> {
131166 return language ;
132167}
133168
134- async function showProblemInternal ( node : IProblem ) : Promise < void > {
169+ async function showProblemInternal ( node : IProblem , muteFlag : boolean = false ) : Promise < void > {
135170 try {
136171 const language : string | undefined = await fetchProblemLanguage ( ) ;
137172 if ( ! language ) {
@@ -168,6 +203,10 @@ async function showProblemInternal(node: IProblem): Promise<void> {
168203
169204 const descriptionConfig : IDescriptionConfiguration = settingUtils . getDescriptionConfiguration ( ) ;
170205 await leetCodeExecutor . showProblem ( node , language , finalPath , descriptionConfig . showInComment ) ;
206+ if ( muteFlag ) {
207+ vscode . window . showInformationMessage ( `Added ${ node . id } .${ node . name } !` ) ;
208+ return ;
209+ }
171210 const promises : any [ ] = [
172211 vscode . window . showTextDocument ( vscode . Uri . file ( finalPath ) , { preview : false , viewColumn : vscode . ViewColumn . One } ) ,
173212 promptHintMessage (
0 commit comments