Skip to content

promptLoadSettings sibling .json is never auto-loaded: restoreState gets the uri as a string and throws on uri.fsPath #202

Description

@Elrond1

Describe the bug
The automatic loading of a sibling settings file (.json next to the waveform, governed by vaporview.promptLoadSettings) never happens — neither the Ask prompt nor the silent Always load. Loading the same file manually (right-click → Load Vaporview Settings, or drag-and-drop) works fine.

Root cause
The extension sends the document uri to the webview as a string:
// document.ts, initViewport message
uri: this.uri.toString(),
The webview echoes that value back in its restoreState message (vscode_wrapper.ts, uri: viewerState.uri). But the handler treats it as a vscode.Uri:

// viewer_provider.ts, restoreState()
const filePath = uri.fsPath.match(/^(.*).[^.]+$/)?.[1] + '.json';
A string has no fsPath, so this line throws TypeError: Cannot read properties of undefined (reading 'match') before fs.existsSync is ever reached. The exception is swallowed by the message dispatch, so nothing appears in the Vaporview output channel — the feature just silently does nothing. (The earlier getDocumentFromUri(uri.toString()) lookup happens to work because String.prototype.toString is a no-op, which masks the type mismatch.)

The manual code paths are unaffected because they pass a real vscode.Uri into loadSettingsFromFileUri directly.

Suggested fix:
Normalize at the top of restoreState (or in the message case):
const fileUri = typeof uri === 'string' ? vscode.Uri.parse(uri) : uri;
and use fileUri.fsPath below. I verified this locally by patching the equivalent line in the bundled dist/extension.js — with the string handled, Always loads the sibling json on every fresh open exactly as documented.

To reproduce:
vaporview.promptLoadSettings = Always (or Ask — the prompt never shows either).
Put wave.json (saved via Ctrl+S from the viewer) next to wave.fst.
Open wave.fst. The waveform loads, the settings file is ignored; no log output.
Environment: VaporView 1.5.4, VS Code on Windows 10, FST dumps from Verilator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions