@@ -879,40 +879,58 @@ export class USSTree extends ZoweTreeProvider<IZoweUSSTreeNode> implements Types
879879 if ( Profiles . getInstance ( ) . validProfile !== Validation . ValidationType . INVALID ) {
880880 let remotepath : string ;
881881 if ( SharedContext . isSessionNotFav ( node ) ) {
882- ZoweLogger . debug ( vscode . l10n . t ( "Prompting the user for a USS path" ) ) ;
883- if ( this . mPersistence . getSearchHistory ( ) . length > 0 ) {
884- const items : vscode . QuickPickItem [ ] = this . mPersistence . getSearchHistory ( ) . map ( ( element ) => new FilterItem ( { text : element } ) ) ;
885- const quickpick = Gui . createQuickPick ( ) ;
886- quickpick . placeholder = vscode . l10n . t ( "Select a filter or type to create a new one" ) ;
887- quickpick . ignoreFocusOut = true ;
888-
889- // Callback updates the "Create a new filter" option as user types
890- quickpick . onDidChangeValue ( ( value ) => {
891- const trimmedValue = value . trim ( ) ;
892- const createPick = trimmedValue
893- ? new FilterDescriptor ( `$(plus) ${ vscode . l10n . t ( "Create a new filter" ) } : "${ value . trim ( ) } "` )
894- : new FilterDescriptor ( USSTree . defaultDialogText ) ;
882+ if ( node . inFilterPrompt ) {
883+ ZoweLogger . debug ( "[USSTree.filterPrompt] Cancelled because filter prompt is already open for this node" ) ;
884+ return ;
885+ }
886+ node . inFilterPrompt = true ;
887+ try {
888+ ZoweLogger . debug ( vscode . l10n . t ( "Prompting the user for a USS path" ) ) ;
889+ if ( this . mPersistence . getSearchHistory ( ) . length > 0 ) {
890+ const items : vscode . QuickPickItem [ ] = this . mPersistence . getSearchHistory ( ) . map ( ( element ) => new FilterItem ( { text : element } ) ) ;
891+ const quickpick = Gui . createQuickPick ( ) ;
892+ quickpick . placeholder = vscode . l10n . t ( "Select a filter or type to create a new one" ) ;
893+ quickpick . ignoreFocusOut = true ;
894+
895+ // Callback updates the "Create a new filter" option as user types
896+ quickpick . onDidChangeValue ( ( value ) => {
897+ const trimmedValue = value . trim ( ) ;
898+ const createPick = trimmedValue
899+ ? new FilterDescriptor ( `$(plus) ${ vscode . l10n . t ( "Create a new filter" ) } : "${ value . trim ( ) } "` )
900+ : new FilterDescriptor ( USSTree . defaultDialogText ) ;
901+ quickpick . items = [ createPick , Constants . SEPARATORS . RECENT_FILTERS , ...items ] ;
902+ } ) ;
903+
904+ const createPick = new FilterDescriptor ( USSTree . defaultDialogText ) ;
895905 quickpick . items = [ createPick , Constants . SEPARATORS . RECENT_FILTERS , ...items ] ;
896- } ) ;
897-
898- const createPick = new FilterDescriptor ( USSTree . defaultDialogText ) ;
899- quickpick . items = [ createPick , Constants . SEPARATORS . RECENT_FILTERS , ...items ] ;
900906
901- quickpick . show ( ) ;
902- const choice = await Gui . resolveQuickPick ( quickpick ) ;
903- quickpick . hide ( ) ;
904- if ( ! choice ) {
905- Gui . showMessage ( vscode . l10n . t ( "No selection made. Operation cancelled." ) ) ;
906- return ;
907- }
908- if ( choice instanceof FilterDescriptor ) {
909- // If user typed something and selected "Create a new filter", use that input
910- if ( quickpick . value && quickpick . value . trim ( ) ) {
911- remotepath = quickpick . value . trim ( ) ;
907+ quickpick . show ( ) ;
908+ const choice = await Gui . resolveQuickPick ( quickpick ) ;
909+ quickpick . hide ( ) ;
910+ if ( ! choice ) {
911+ Gui . showMessage ( vscode . l10n . t ( "No selection made. Operation cancelled." ) ) ;
912+ return ;
913+ }
914+ if ( choice instanceof FilterDescriptor ) {
915+ // If user typed something and selected "Create a new filter", use that input
916+ if ( quickpick . value && quickpick . value . trim ( ) ) {
917+ remotepath = quickpick . value . trim ( ) ;
918+ } else {
919+ // Fall back to input box if no text was entered
920+ const options : vscode . InputBoxOptions = {
921+ placeHolder : vscode . l10n . t ( "New filter" ) ,
922+ validateInput : ( input : string ) => ( input . length > 0 ? null : vscode . l10n . t ( "Please enter a valid USS path." ) ) ,
923+ } ;
924+ remotepath = await Gui . showInputBox ( options ) ;
925+ if ( remotepath == null ) {
926+ return ;
927+ }
928+ }
912929 } else {
913- // Fall back to input box if no text was entered
930+ // User selected an existing filter - show input box with the filter pre-filled for editing
914931 const options : vscode . InputBoxOptions = {
915932 placeHolder : vscode . l10n . t ( "New filter" ) ,
933+ value : choice . label , // Pre-fill with the selected filter
916934 validateInput : ( input : string ) => ( input . length > 0 ? null : vscode . l10n . t ( "Please enter a valid USS path." ) ) ,
917935 } ;
918936 remotepath = await Gui . showInputBox ( options ) ;
@@ -921,27 +939,18 @@ export class USSTree extends ZoweTreeProvider<IZoweUSSTreeNode> implements Types
921939 }
922940 }
923941 } else {
924- // User selected an existing filter - show input box with the filter pre-filled for editing
942+ // No search history, use input box directly
925943 const options : vscode . InputBoxOptions = {
926944 placeHolder : vscode . l10n . t ( "New filter" ) ,
927- value : choice . label , // Pre-fill with the selected filter
928945 validateInput : ( input : string ) => ( input . length > 0 ? null : vscode . l10n . t ( "Please enter a valid USS path." ) ) ,
929946 } ;
930947 remotepath = await Gui . showInputBox ( options ) ;
931948 if ( remotepath == null ) {
932949 return ;
933950 }
934951 }
935- } else {
936- // No search history, use input box directly
937- const options : vscode . InputBoxOptions = {
938- placeHolder : vscode . l10n . t ( "New filter" ) ,
939- validateInput : ( input : string ) => ( input . length > 0 ? null : vscode . l10n . t ( "Please enter a valid USS path." ) ) ,
940- } ;
941- remotepath = await Gui . showInputBox ( options ) ;
942- if ( remotepath == null ) {
943- return ;
944- }
952+ } finally {
953+ node . inFilterPrompt = false ;
945954 }
946955 } else {
947956 // executing search from saved search in favorites
0 commit comments