@@ -838,11 +838,50 @@ ClassMethod %OnDashboardAction(pAction As %String, pContext As %ZEN.proxyObject)
838838 clsUri = DocumentContentProvider . getUri ( `${ cls } .cls` , undefined , undefined , undefined , wsFolder . uri ) ;
839839 } else {
840840 // Ask the user for the URI
841- clsUri = await vscode . window . showSaveDialog ( {
842- defaultUri : getLocalUri ( cls , wsFolder ) , // Use the export settings to determine the default URI
843- filters : {
844- Classes : [ "cls" ] ,
845- } ,
841+ const localUri = getLocalUri ( cls , wsFolder ) ;
842+ clsUri = await new Promise < vscode . Uri > ( ( resolve ) => {
843+ const inputBox = vscode . window . createInputBox ( ) ;
844+ inputBox . ignoreFocusOut = true ;
845+ inputBox . buttons = [ { iconPath : new vscode . ThemeIcon ( "save-as" ) , tooltip : "Show 'Save As' dialog" } ] ;
846+ inputBox . prompt = `The path is relative to the workspace folder root (${ wsFolder . uri . toString ( true ) } ). Intermediate folders that do not exist will be created. Click the 'Save As' icon to open the standard save dialog instead.` ;
847+ inputBox . title = "Enter a file path for the new class" ;
848+ inputBox . value = localUri . path . slice ( wsFolder . uri . path . length ) ;
849+ inputBox . valueSelection = [ inputBox . value . length , inputBox . value . length ] ;
850+ let showingSave = false ;
851+ inputBox . onDidTriggerButton ( ( ) => {
852+ // User wants to use the save dialog
853+ showingSave = true ;
854+ inputBox . hide ( ) ;
855+ vscode . window
856+ . showSaveDialog ( {
857+ defaultUri : localUri ,
858+ filters : {
859+ Classes : [ "cls" ] ,
860+ } ,
861+ } )
862+ . then (
863+ ( u ) => resolve ( u ) ,
864+ ( ) => resolve ( undefined )
865+ ) ;
866+ } ) ;
867+ inputBox . onDidAccept ( ( ) => {
868+ if ( typeof inputBox . validationMessage != "string" ) {
869+ resolve (
870+ wsFolder . uri . with ( {
871+ path : `${ wsFolder . uri . path } ${ ! wsFolder . uri . path . endsWith ( "/" ) ? "/" : "" } ${ inputBox . value . replace ( / ^ \/ + / , "" ) } ` ,
872+ } )
873+ ) ;
874+ inputBox . hide ( ) ;
875+ }
876+ } ) ;
877+ inputBox . onDidHide ( ( ) => {
878+ if ( ! showingSave ) resolve ( undefined ) ;
879+ inputBox . dispose ( ) ;
880+ } ) ;
881+ inputBox . onDidChangeValue ( ( value ) => {
882+ inputBox . validationMessage = value . endsWith ( ".cls" ) ? undefined : "File extension must be .cls" ;
883+ } ) ;
884+ inputBox . show ( ) ;
846885 } ) ;
847886 }
848887
0 commit comments