stevedlawrence commented on code in PR #117: URL: https://github.com/apache/daffodil-vscode/pull/117#discussion_r883897532
########## src/omega_edit/client.ts: ########## @@ -0,0 +1,152 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as vscode from 'vscode' +import * as fs from 'fs' +import { createSession, destroySession } from 'omega-edit/session' +import { createViewport } from 'omega-edit/viewport' +import { getVersion } from 'omega-edit/version' +import { startServer, stopServer } from './server' +import { randomId, viewportSubscribe } from './utils' +import { OmegaEdit } from './omega_edit' + +let serverRunning = false + +async function cleanupViewportSession( + sessionId: string, + viewportIds: Array<string> +) { + await destroySession(sessionId) +} + +export function activate(ctx: vscode.ExtensionContext) { + ctx.subscriptions.push( + vscode.commands.registerCommand('omega_edit.version', async () => { + if (!serverRunning) { + await startServer(ctx) + serverRunning = true + } + let v = await getVersion() + vscode.window.showInformationMessage(v) + }) + ) + + ctx.subscriptions.push( + vscode.commands.registerCommand('data.edit', async () => { + if (!serverRunning) { + await startServer(ctx) + serverRunning = true + } + + let panel = vscode.window.createWebviewPanel( + 'viewport', + 'Data Editor', + vscode.ViewColumn.One, + { + enableScripts: true, + } + ) + + let fileToEdit = await vscode.window + .showOpenDialog({ + canSelectMany: false, + openLabel: 'Select', + canSelectFiles: true, + canSelectFolders: false, + }) + .then((fileUri) => { + if (fileUri && fileUri[0]) { + return fileUri[0].fsPath + } + }) + + panel.webview.html = getWebviewContent(ctx) + + let s = await createSession(fileToEdit, '') Review Comment: Good to know. I don't know if I have a strong preference and it's totally fine if that's kind of the convention that typescript/npm stuff usually follows. I think I personally prefer the latter -- 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]
