Shanedell commented on code in PR #509:
URL: https://github.com/apache/daffodil-vscode/pull/509#discussion_r1143885018
##########
src/omega_edit/client.ts:
##########
@@ -45,19 +45,21 @@ async function getOmegaEditPort(port: number | undefined =
undefined) {
const defaultServerPort = vscode.workspace
.getConfiguration('dataEditor')
.get<number>('defaultServerPort', serverPort)
- const portEntered = await vscode.window.showInputBox({
- prompt: 'Enter port number to run omega-edit server on',
- value: defaultServerPort.toString(),
- })
- if (portEntered) {
- serverPort = parseInt(portEntered)
- } else {
- serverPort = 0
- throw Error('Bad port entered')
- }
+ serverPort = defaultServerPort
Review Comment:
Update function `getOmegaEditPort` to be
```ts
async function getOmegaEditPort() {
const defaultServerPort = vscode.workspace
.getConfiguration('dataEditor')
.get<number>('serverPort', serverPort)
serverPort = defaultServerPort
}
```
This will always assign a port. Maybe add error checking if the `serverPort
=== 0` allow this assignment to happen otherwise throw the error you have now
since the editor is running already. Possibly
```ts
if (serverPort === 0) {
const defaultServerPort = vscode.workspace
.getConfiguration('dataEditor')
.get<number>('serverPort', serverPort)
serverPort = defaultServerPort
} else {
throw 'Data Editor currently only supports a single instance.'
}
```
NOTE: Used `serverPort` instead of `defaultServerPort` as I think it should
be renamed. See
https://github.com/apache/daffodil-vscode/pull/509#discussion_r1143887396
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]