@@ -2,7 +2,7 @@ import * as vscode from "vscode";
22import WebSocket = require( "ws" ) ;
33
44import { AtelierAPI } from "../api" ;
5- import { connectionTarget , currentFile , handleError , notIsfs , outputChannel } from "../utils" ;
5+ import { connectionTarget , currentFile , getWsServerConnection , handleError , notIsfs , outputChannel } from "../utils" ;
66import { config , iscIcon , resolveConnectionSpec } from "../extension" ;
77
88const keys = {
@@ -755,26 +755,6 @@ function terminalConfigForUri(
755755 } ;
756756}
757757
758- async function workspaceUriForTerminal ( throwErrors = false ) {
759- let uri : vscode . Uri ;
760- const workspaceFolders = vscode . workspace . workspaceFolders || [ ] ;
761- if ( workspaceFolders . length == 0 ) {
762- reportError ( "Lite Terminal requires an open workspace." , throwErrors ) ;
763- } else if ( workspaceFolders . length == 1 ) {
764- // Use the current connection
765- uri = workspaceFolders [ 0 ] . uri ;
766- } else {
767- // Pick from the workspace folders
768- uri = (
769- await vscode . window . showWorkspaceFolderPick ( {
770- ignoreFocusOut : true ,
771- placeHolder : "Pick the workspace folder to get server connection information from" ,
772- } )
773- ) ?. uri ;
774- }
775- return uri ;
776- }
777-
778758export async function launchWebSocketTerminal ( targetUri ?: vscode . Uri ) : Promise < void > {
779759 // Determine the server to connect to
780760 if ( targetUri ) {
@@ -784,10 +764,9 @@ export async function launchWebSocketTerminal(targetUri?: vscode.Uri): Promise<v
784764 const serverName = notIsfs ( targetUri ) ? config ( "conn" , configName ) . server : configName ;
785765 await resolveConnectionSpec ( serverName ) ;
786766 } else {
787- targetUri = currentFile ( ) ?. uri ;
788- if ( ! targetUri ) {
789- targetUri = await workspaceUriForTerminal ( ) ;
790- }
767+ // Determine the server connection to use
768+ targetUri = currentFile ( ) ?. uri ?? ( await getWsServerConnection ( "2023.2.0" ) ) ;
769+ if ( ! targetUri ) return ;
791770 }
792771 const api = new AtelierAPI ( targetUri ) ;
793772
@@ -806,14 +785,16 @@ export async function launchWebSocketTerminal(targetUri?: vscode.Uri): Promise<v
806785export class WebSocketTerminalProfileProvider implements vscode . TerminalProfileProvider {
807786 async provideTerminalProfile ( ) : Promise < vscode . TerminalProfile > {
808787 // Determine the server connection to use
809- const uri : vscode . Uri = await workspaceUriForTerminal ( true ) ;
788+ const uri : vscode . Uri = await getWsServerConnection ( "2023.2.0" ) ;
810789
811790 if ( uri ) {
812791 // Get the terminal configuration. Will throw if there's an error.
813792 const terminalOpts = terminalConfigForUri ( new AtelierAPI ( uri ) , uri , true ) ;
814793 return new vscode . TerminalProfile ( terminalOpts ) ;
815- } else {
816- throw new Error ( "Lite Terminal requires a selected workspace folder." ) ;
794+ } else if ( uri == undefined ) {
795+ throw new Error (
796+ "Lite Terminal requires an active server connection to InterSystems IRIS version 2023.2 or above."
797+ ) ;
817798 }
818799 }
819800}
0 commit comments