From 0ce43f66285c7dee9a94575d8998bbaa50a7945a Mon Sep 17 00:00:00 2001 From: LSTM-Kirigaya <1193466151@qq.com> Date: Tue, 7 Jan 2025 21:51:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20netlist=20=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E7=9A=84=E5=8F=A5=E6=9F=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/function/dide-netlist/index.ts | 16 +++++++++++++--- src/function/dide-netlist/worker.ts | 18 ++++++++++++++++++ src/function/lsp-client/config.ts | 8 ++++++++ src/function/lsp/linter/manager.ts | 21 +++++---------------- 4 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 src/function/dide-netlist/worker.ts diff --git a/src/function/dide-netlist/index.ts b/src/function/dide-netlist/index.ts index ff8470b..caf6e6c 100644 --- a/src/function/dide-netlist/index.ts +++ b/src/function/dide-netlist/index.ts @@ -15,6 +15,7 @@ import { HdlLangID } from '../../global/enum'; import { getIconConfig } from '../../hdlFs/icons'; import { getDiskLetters, PathSet } from '../../global/util'; import { gotoDefinition, saveAsPdf, saveAsSvg } from './api'; +import { Worker } from 'worker_threads'; type SynthMode = 'before' | 'after' | 'RTL'; @@ -99,11 +100,20 @@ class Netlist { location: vscode.ProgressLocation.Notification, title: t('info.netlist.generate-network'), cancellable: true - }, async () => { - const instance = await WebAssembly.instantiate(wasm, { + }, async (_, token) => { + token.onCancellationRequested(() => { + console.log('cancel'); + fs.closeSync(fd); + }); + + const instance = WebAssembly.instantiate(wasm, { wasi_snapshot_preview1: wasi.wasiImport }); - const exitCode = wasi.start(instance); + try { + const exitCode = wasi.start(instance); + } catch (error) { + console.error(error); + } }); if (!fs.existsSync(targetJson)) { diff --git a/src/function/dide-netlist/worker.ts b/src/function/dide-netlist/worker.ts new file mode 100644 index 0000000..7cc5be7 --- /dev/null +++ b/src/function/dide-netlist/worker.ts @@ -0,0 +1,18 @@ +import { isMainThread, Worker, parentPort } from 'worker_threads'; + +if (parentPort) { + parentPort.on('message', message => { + const command = message.command as string; + const data = message.data; + + switch (command) { + case 'ys': + + break; + + default: + break; + } + }); +} + diff --git a/src/function/lsp-client/config.ts b/src/function/lsp-client/config.ts index c70446f..40f52b3 100644 --- a/src/function/lsp-client/config.ts +++ b/src/function/lsp-client/config.ts @@ -165,6 +165,14 @@ export async function registerLinter(client: LanguageClient) { lspLinter.vhdlLinterManager.updateStatusBar(); } }); + + // 切换标签页时的行为 + vscode.window.onDidChangeActiveTextEditor(editor => { + if (!editor) { + return; + } + console.log('change to ', editor); + }) } /** diff --git a/src/function/lsp/linter/manager.ts b/src/function/lsp/linter/manager.ts index 1e34530..809d641 100644 --- a/src/function/lsp/linter/manager.ts +++ b/src/function/lsp/linter/manager.ts @@ -340,22 +340,11 @@ export async function refreshWorkspaceDiagonastics( await publishDiagnostics(client, path); } - const tabs = vscode.window.tabGroups.all; - const tabArray = tabs.flatMap(group => { - const files = []; - for (const tab of group.tabs) { - if (tab.input) { - const doc = tab.input as vscode.TabInputText; - if (doc.uri) { - const absPath = hdlPath.toEscapePath(doc.uri.fsPath); - files.push(absPath); - } - } - } - return files; - }); - - await asyncConsumer(tabArray, consumer, parallelChunk, progress); + const activeEditor = vscode.window.activeTextEditor; + if (activeEditor) { + const path = hdlPath.toEscapePath(activeEditor.document.fileName); + await asyncConsumer([path], consumer, parallelChunk, progress); + } } else { if (!isInitialise) { // shutdown, 如果是初始化阶段,什么都不需要做