@@ -130,15 +130,11 @@ const openJshellInContextOfProject = async (ctx: any) => {
130130 if ( await isNbCommandRegistered ( nbCommands . openJshellInProject ) ) {
131131 const additionalContext = window . activeTextEditor ?. document . uri . toString ( ) ;
132132 const res = await commands . executeCommand < openJshellNbResponse > ( nbCommands . openJshellInProject , ctx ?. toString ( ) , additionalContext ) ;
133- const { envMap, finalArgs } = passArgsToTerminal ( res . vmOptions ) ;
134- const jshellPath = res . jdkPath ? path . join ( res . jdkPath , "bin" , "jshell" ) : "jshell" ;
135- // Direct sendText is not working since it truncates the command exceeding a certain length.
136- // Open issues on vscode: 130688, 134324 and many more
137- // So, workaround by setting env variables.
133+ const jshell = os . type ( ) === 'Windows_NT' ? 'jshell.exe' : 'jshell' ;
134+ const jshellPath = res . jdkPath ? path . join ( res . jdkPath , "bin" , jshell ) : "jshell" ;
138135 const terminal = window . createTerminal ( {
139- name : "Jshell instance" , env : envMap
136+ name : "Jshell instance" , shellPath : jshellPath , shellArgs : res . vmOptions
140137 } ) ;
141- terminal . sendText ( `${ jshellPath } ${ finalArgs . join ( ' ' ) } ` , true ) ;
142138 terminal . show ( ) ;
143139 } else {
144140 throw l10n . value ( "jdk.extension.error_msg.doesntSupportJShellExecution" , { client : client ?. name } ) ;
@@ -148,20 +144,6 @@ const openJshellInContextOfProject = async (ctx: any) => {
148144 LOGGER . error ( `Error occurred while launching jshell in project context : ${ isError ( error ) ? error . message : error } ` ) ;
149145 }
150146}
151-
152- const passArgsToTerminal = ( args : string [ ] ) : { envMap : { [ key : string ] : string } , finalArgs : string [ ] } => {
153- const envMap : { [ key : string ] : string } = { } ;
154- const finalArgs = args . map ( ( arg , index ) => {
155- if ( arg . startsWith ( '-' ) || arg . startsWith ( '--' ) ) {
156- return arg ;
157- }
158- const envName = `jshellArgsEnv${ index } ` ;
159- envMap [ envName ] = arg ;
160- return `$${ envName } ` ;
161- } ) ;
162- return { envMap, finalArgs } ;
163- }
164-
165147const notebookChangeProjectContextHandler = async ( ctx : INotebookToolbar ) => {
166148 try {
167149 const uri : Uri = ctx . notebookEditor . notebookUri ;
0 commit comments