@@ -9,6 +9,14 @@ import {
99import { SavedContext } from '@/types/context'
1010import { dictionary } from '@shared/constants/dictionary'
1111
12+ const PROMPT_ENTER_CONTEXT_NAME = 'Enter a name for this context'
13+ const PLACEHOLDER_CONTEXT_NAME = 'e.g., Backend API Context'
14+ const VALIDATION_CONTEXT_NAME_EMPTY = 'Context name cannot be empty.'
15+ const LABEL_BACK = '$(arrow-left) Back'
16+ const LABEL_NEW_SAVED_CONTEXT = '$(add) New saved context...'
17+ const PLACEHOLDER_SELECT_OR_CREATE_CONTEXT =
18+ 'Select existing context to overwrite or create a new one'
19+
1220function condense_paths (
1321 paths : string [ ] ,
1422 workspace_root : string ,
@@ -311,7 +319,6 @@ export function save_context_command(
311319 return a . localeCompare ( b )
312320 } )
313321
314- const BACK_LABEL = '$(arrow-left) Back'
315322 let show_storage_selection = true
316323 while ( show_storage_selection ) {
317324 show_storage_selection = false
@@ -388,23 +395,19 @@ export function save_context_command(
388395
389396 if ( existing_context_names . length == 0 ) {
390397 context_name = await vscode . window . showInputBox ( {
391- prompt : 'Enter a name for this context' ,
392- placeHolder : 'e.g., Backend API Context' ,
398+ prompt : PROMPT_ENTER_CONTEXT_NAME ,
399+ placeHolder : PLACEHOLDER_CONTEXT_NAME ,
393400 validateInput : ( value ) =>
394- value . trim ( ) . length > 0
395- ? null
396- : 'Context name cannot be empty.'
401+ value . trim ( ) . length > 0 ? null : VALIDATION_CONTEXT_NAME_EMPTY
397402 } )
398403
399404 if ( ! context_name ) {
400405 return
401406 }
402407 } else {
403408 const quick_pick_items = [
404- { label : BACK_LABEL } ,
405- {
406- label : '$(add) Create new...'
407- } ,
409+ { label : LABEL_BACK } ,
410+ { label : LABEL_NEW_SAVED_CONTEXT } ,
408411 { label : '' , kind : vscode . QuickPickItemKind . Separator } ,
409412 ...existing_context_names . map ( ( name ) => {
410413 const context_info = all_contexts_map . get ( name ) !
@@ -436,28 +439,27 @@ export function save_context_command(
436439 const selected_item = await vscode . window . showQuickPick (
437440 quick_pick_items ,
438441 {
439- placeHolder :
440- 'Select existing context to overwrite or create a new one'
442+ placeHolder : PLACEHOLDER_SELECT_OR_CREATE_CONTEXT
441443 }
442444 )
443445
444446 if ( ! selected_item ) {
445447 return
446448 }
447449
448- if ( selected_item . label === BACK_LABEL ) {
450+ if ( selected_item . label === LABEL_BACK ) {
449451 show_storage_selection = true
450452 continue
451453 }
452454
453- if ( selected_item . label == '$(add) Create new...' ) {
455+ if ( selected_item . label == LABEL_NEW_SAVED_CONTEXT ) {
454456 context_name = await vscode . window . showInputBox ( {
455- prompt : 'Enter a name for this context' ,
456- placeHolder : 'e.g., Backend API Context' ,
457+ prompt : PROMPT_ENTER_CONTEXT_NAME ,
458+ placeHolder : PLACEHOLDER_CONTEXT_NAME ,
457459 validateInput : ( value ) =>
458460 value . trim ( ) . length > 0
459461 ? null
460- : 'Context name cannot be empty.'
462+ : VALIDATION_CONTEXT_NAME_EMPTY
461463 } )
462464
463465 if ( ! context_name ) {
@@ -579,10 +581,10 @@ export function save_context_command(
579581
580582 if ( saved_contexts . length == 0 ) {
581583 context_name = await vscode . window . showInputBox ( {
582- prompt : 'Enter a name for this context' ,
583- placeHolder : 'e.g., Backend API Context' ,
584+ prompt : PROMPT_ENTER_CONTEXT_NAME ,
585+ placeHolder : PLACEHOLDER_CONTEXT_NAME ,
584586 validateInput : ( value ) =>
585- value . trim ( ) . length > 0 ? null : 'Context name cannot be empty.'
587+ value . trim ( ) . length > 0 ? null : VALIDATION_CONTEXT_NAME_EMPTY
586588 } )
587589
588590 if ( ! context_name ) {
@@ -594,10 +596,8 @@ export function save_context_command(
594596 )
595597
596598 const quick_pick_items = [
597- { label : BACK_LABEL } ,
598- {
599- label : '$(add) Create new...'
600- } ,
599+ { label : LABEL_BACK } ,
600+ { label : LABEL_NEW_SAVED_CONTEXT } ,
601601 { label : '' , kind : vscode . QuickPickItemKind . Separator } ,
602602 ...saved_contexts . map ( ( context ) => ( {
603603 label : context . name ,
@@ -610,28 +610,25 @@ export function save_context_command(
610610 const selected_item = await vscode . window . showQuickPick (
611611 quick_pick_items ,
612612 {
613- placeHolder :
614- 'Select existing context to overwrite or create a new one'
613+ placeHolder : PLACEHOLDER_SELECT_OR_CREATE_CONTEXT
615614 }
616615 )
617616
618617 if ( ! selected_item ) {
619618 return
620619 }
621620
622- if ( selected_item . label === BACK_LABEL ) {
621+ if ( selected_item . label === LABEL_BACK ) {
623622 show_storage_selection = true
624623 continue
625624 }
626625
627- if ( selected_item . label == '$(add) Create new...' ) {
626+ if ( selected_item . label == LABEL_NEW_SAVED_CONTEXT ) {
628627 context_name = await vscode . window . showInputBox ( {
629- prompt : 'Enter a name for this context' ,
630- placeHolder : 'e.g., Backend API Context' ,
628+ prompt : PROMPT_ENTER_CONTEXT_NAME ,
629+ placeHolder : PLACEHOLDER_CONTEXT_NAME ,
631630 validateInput : ( value ) =>
632- value . trim ( ) . length > 0
633- ? null
634- : 'Context name cannot be empty.'
631+ value . trim ( ) . length > 0 ? null : VALIDATION_CONTEXT_NAME_EMPTY
635632 } )
636633
637634 if ( ! context_name ) {
0 commit comments