feature: 实现点击 VCD 文件时 Surfer 显示波形
- VCDViewerEditorProvider 现在接收并持有 vcdFileServer 实例 - createFromWebviewPanel 方法传递 vcdFileServer 参数 - 确保自定义编辑器打开 VCD 文件时能够通过 HTTP 服务器加载波形数据
This commit is contained in:
@ -175,7 +175,7 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
);
|
||||
|
||||
// 注册 VCD 自定义编辑器
|
||||
const vcdEditorProvider = VCDViewerEditorProvider.register(context);
|
||||
const vcdEditorProvider = VCDViewerEditorProvider.register(context, vcdFileServer);
|
||||
|
||||
// 添加到订阅
|
||||
context.subscriptions.push(
|
||||
|
||||
@ -7,8 +7,8 @@ import { VCDFileServer } from "../services/vcdFileServer";
|
||||
* VCD 波形查看器自定义编辑器提供者
|
||||
*/
|
||||
export class VCDViewerEditorProvider implements vscode.CustomReadonlyEditorProvider {
|
||||
public static register(context: vscode.ExtensionContext): vscode.Disposable {
|
||||
const provider = new VCDViewerEditorProvider(context);
|
||||
public static register(context: vscode.ExtensionContext, vcdFileServer: VCDFileServer): vscode.Disposable {
|
||||
const provider = new VCDViewerEditorProvider(context, vcdFileServer);
|
||||
const providerRegistration = vscode.window.registerCustomEditorProvider(
|
||||
"ic-coder.vcdViewer",
|
||||
provider,
|
||||
@ -21,7 +21,10 @@ export class VCDViewerEditorProvider implements vscode.CustomReadonlyEditorProvi
|
||||
return providerRegistration;
|
||||
}
|
||||
|
||||
constructor(private readonly context: vscode.ExtensionContext) {}
|
||||
constructor(
|
||||
private readonly context: vscode.ExtensionContext,
|
||||
private readonly vcdFileServer: VCDFileServer
|
||||
) {}
|
||||
|
||||
async openCustomDocument(
|
||||
uri: vscode.Uri,
|
||||
@ -48,7 +51,8 @@ export class VCDViewerEditorProvider implements vscode.CustomReadonlyEditorProvi
|
||||
VCDViewerPanel.createFromWebviewPanel(
|
||||
webviewPanel,
|
||||
this.context.extensionUri,
|
||||
document.uri.fsPath
|
||||
document.uri.fsPath,
|
||||
this.vcdFileServer
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -140,9 +144,10 @@ export class VCDViewerPanel {
|
||||
public static createFromWebviewPanel(
|
||||
panel: vscode.WebviewPanel,
|
||||
extensionUri: vscode.Uri,
|
||||
vcdFilePath: string
|
||||
vcdFilePath: string,
|
||||
vcdFileServer?: VCDFileServer
|
||||
) {
|
||||
const viewer = new VCDViewerPanel(panel, extensionUri);
|
||||
const viewer = new VCDViewerPanel(panel, extensionUri, vcdFileServer);
|
||||
viewer.loadVCDFile(vcdFilePath);
|
||||
return viewer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user