@@ -212,27 +212,71 @@ export class SnoozeInlineCompletion extends Action2 {
212212 private async getDurationFromUser ( quickInputService : IQuickInputService , storageService : IStorageService ) : Promise < number | undefined > {
213213 const lastSelectedDuration = storageService . getNumber ( LAST_SNOOZE_DURATION_KEY , StorageScope . PROFILE , 300_000 ) ;
214214
215- const items : ( IQuickPickItem & { value : number } ) [ ] = [
216- { label : ' 1 minute' , id : '1' , value : 60_000 } ,
217- { label : ' 5 minutes' , id : '5' , value : 300_000 } ,
218- { label : ' 10 minutes' , id : '10' , value : 600_000 } ,
219- { label : ' 15 minutes' , id : '15' , value : 900_000 } ,
220- { label : ' 30 minutes' , id : '30' , value : 1_800_000 } ,
221- { label : ' 60 minutes' , id : '60' , value : 3_600_000 }
215+ const predefinedItems : ( IQuickPickItem & { value : number } ) [ ] = [
216+ { label : localize ( 'snooze.1minute' , " 1 minute" ) , id : '1' , value : 60_000 } ,
217+ { label : localize ( 'snooze.5minutes' , " 5 minutes" ) , id : '5' , value : 300_000 } ,
218+ { label : localize ( 'snooze.10minutes' , " 10 minutes" ) , id : '10' , value : 600_000 } ,
219+ { label : localize ( 'snooze.15minutes' , " 15 minutes" ) , id : '15' , value : 900_000 } ,
220+ { label : localize ( 'snooze.30minutes' , " 30 minutes" ) , id : '30' , value : 1_800_000 } ,
221+ { label : localize ( 'snooze.60minutes' , " 60 minutes" ) , id : '60' , value : 3_600_000 } ,
222222 ] ;
223223
224+ let items = predefinedItems ;
225+ if ( lastSelectedDuration > 0 && ! predefinedItems . some ( item => item . value === lastSelectedDuration ) ) {
226+ const minutes = lastSelectedDuration / 60_000 ;
227+ const customItem : IQuickPickItem & { value : number } = {
228+ label : localize ( 'snooze.lastCustom' , "{0} minutes (Last used)" , minutes ) ,
229+ id : 'last-custom' ,
230+ value : lastSelectedDuration ,
231+ description : localize ( 'snooze.lastUsed' , "Last used custom duration" ) ,
232+ } ;
233+ const index = predefinedItems . findIndex ( item => item . value > lastSelectedDuration ) ;
234+ if ( index === - 1 ) {
235+ items = [ ...predefinedItems , customItem ] ;
236+ } else {
237+ items = [ ...predefinedItems . slice ( 0 , index ) , customItem , ...predefinedItems . slice ( index ) ] ;
238+ }
239+ }
240+
241+ items . push ( { label : localize ( 'snooze.custom' , "Custom..." ) , id : 'custom' , value : - 1 } ) ;
242+
224243 const picked = await quickInputService . pick ( items , {
225244 placeHolder : localize ( 'snooze.placeholder' , "Select snooze duration for Inline Suggestions" ) ,
226245 activeItem : items . find ( item => item . value === lastSelectedDuration ) ,
227246 } ) ;
228247
229248 if ( picked ) {
249+ if ( picked . id === 'custom' ) {
250+ return this . getCustomDurationFromUser ( quickInputService , storageService ) ;
251+ }
230252 storageService . store ( LAST_SNOOZE_DURATION_KEY , picked . value , StorageScope . PROFILE , StorageTarget . USER ) ;
231253 return picked . value ;
232254 }
233255
234256 return undefined ;
235257 }
258+
259+ private async getCustomDurationFromUser ( quickInputService : IQuickInputService , storageService : IStorageService ) : Promise < number | undefined > {
260+ const customMinutes = await quickInputService . input ( {
261+ placeHolder : localize ( 'snooze.customPlaceholder' , "Duration in minutes (e.g. 90)" ) ,
262+ prompt : localize ( 'snooze.customPrompt' , "Enter snooze duration in minutes" ) ,
263+ validateInput : async ( value ) => {
264+ const n = Number ( value ) ;
265+ if ( isNaN ( n ) || n <= 0 || ! Number . isFinite ( n ) ) {
266+ return localize ( 'snooze.invalidInput' , "Please enter a positive number" ) ;
267+ }
268+ return undefined ;
269+ }
270+ } ) ;
271+
272+ if ( customMinutes ) {
273+ const ms = Number ( customMinutes ) * 60_000 ;
274+ storageService . store ( LAST_SNOOZE_DURATION_KEY , ms , StorageScope . PROFILE , StorageTarget . USER ) ;
275+ return ms ;
276+ }
277+
278+ return undefined ;
279+ }
236280}
237281
238282export class CancelSnoozeInlineCompletion extends Action2 {
0 commit comments