@@ -34,7 +34,6 @@ export class CodeSnippetService {
3434 this . settingManager . get ( 'snippets' ) . user as JSONArray
3535 ) ;
3636
37- console . log ( userSnippets . length ) ;
3837 if ( userSnippets . length !== 0 ) {
3938 this . codeSnippetList = userSnippets ;
4039 } else {
@@ -46,8 +45,6 @@ export class CodeSnippetService {
4645 'snippets' ,
4746 ( this . codeSnippetList as unknown ) as PartialJSONValue
4847 ) ;
49-
50- console . log ( this . codeSnippetList ) ;
5148 }
5249
5350 private convertToICodeSnippetList ( snippets : JSONArray ) : ICodeSnippet [ ] {
@@ -66,7 +63,6 @@ export class CodeSnippetService {
6663 }
6764
6865 static getCodeSnippetService ( ) : CodeSnippetService {
69- console . log ( this . codeSnippetService ) ;
7066 return this . codeSnippetService ;
7167 }
7268
@@ -80,19 +76,10 @@ export class CodeSnippetService {
8076 ) ;
8177 }
8278
83- // isValidSnippet(): boolean {
84- // // check duplicate name
85- // // check required fields
86-
87- // }
88-
8979 async addSnippet ( snippet : ICodeSnippet ) : Promise < boolean > {
9080 const id = snippet . id ;
91- console . log ( id ) ;
9281 this . codeSnippetList . splice ( id , 0 , snippet ) ;
9382
94- console . log ( this . codeSnippetList ) ;
95-
9683 const numSnippets = this . codeSnippetList . length ;
9784
9885 // update id's of snippets.
@@ -101,9 +88,6 @@ export class CodeSnippetService {
10188 this . codeSnippetList [ i ] . id += 1 ;
10289 }
10390
104- console . log ( this . codeSnippetList ) ;
105-
106- console . log ( this . codeSnippetList ) ;
10791 await this . settingManager
10892 . set ( 'snippets' , ( this . codeSnippetList as unknown ) as PartialJSONValue )
10993 . catch ( ( _ ) => {
@@ -142,13 +126,6 @@ export class CodeSnippetService {
142126 }
143127
144128 async renameSnippet ( oldName : string , newName : string ) : Promise < boolean > {
145- console . log ( 'renaming' ) ;
146- try {
147- this . duplicateNameExists ( newName ) ;
148- } catch ( e ) {
149- return false ;
150- }
151-
152129 for ( const snippet of this . codeSnippetList ) {
153130 if ( snippet . name === oldName ) {
154131 snippet . name = newName ;
@@ -163,28 +140,26 @@ export class CodeSnippetService {
163140 return true ;
164141 }
165142
166- duplicateNameExists ( newName : string ) : void {
143+ duplicateNameExists ( newName : string ) : boolean {
167144 for ( const snippet of this . codeSnippetList ) {
168145 if ( snippet . name . toLowerCase ( ) === newName . toLowerCase ( ) ) {
169- throw Error ( 'Duplicate Name of Code Snippet' ) ;
146+ return true ;
170147 }
171148 }
149+ return false ;
172150 }
173151
174152 async modifyExistingSnippet (
175153 oldName : string ,
176154 newSnippet : ICodeSnippet
177155 ) : Promise < boolean > {
178- console . log ( this . codeSnippetList ) ;
179156 for ( const snippet of this . codeSnippetList ) {
180157 if ( snippet . name . toLowerCase ( ) === oldName . toLowerCase ( ) ) {
181158 this . codeSnippetList . splice ( snippet . id , 1 , newSnippet ) ;
182159 break ;
183160 }
184161 }
185162
186- console . log ( this . codeSnippetList ) ;
187-
188163 await this . settingManager
189164 . set ( 'snippets' , ( this . codeSnippetList as unknown ) as PartialJSONValue )
190165 . catch ( ( _ ) => {
@@ -194,8 +169,6 @@ export class CodeSnippetService {
194169 }
195170
196171 async moveSnippet ( fromIdx : number , toIdx : number ) : Promise < boolean > {
197- console . log ( fromIdx ) ;
198- console . log ( toIdx ) ;
199172 if ( toIdx > fromIdx ) {
200173 toIdx = toIdx - 1 ;
201174 }
0 commit comments