添加 netlist 取消的句柄

This commit is contained in:
锦恢 2025-01-07 21:51:49 +08:00
parent 6834968bc5
commit 0ce43f6628
4 changed files with 44 additions and 19 deletions

View File

@ -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
});
try {
const exitCode = wasi.start(instance);
} catch (error) {
console.error(error);
}
});
if (!fs.existsSync(targetJson)) {

View File

@ -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;
}
});
}

View File

@ -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);
})
}
/**

View File

@ -340,22 +340,11 @@ export async function refreshWorkspaceDiagonastics(
await publishDiagnostics(client, path);
}
const tabs = vscode.window.tabGroups.all;
const tabArray = tabs.flatMap<AbsPath>(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);
const activeEditor = vscode.window.activeTextEditor;
if (activeEditor) {
const path = hdlPath.toEscapePath(activeEditor.document.fileName);
await asyncConsumer([path], consumer, parallelChunk, progress);
}
}
}
return files;
});
await asyncConsumer(tabArray, consumer, parallelChunk, progress);
} else {
if (!isInitialise) {
// shutdown, 如果是初始化阶段,什么都不需要做