Description
Currently, the extension only scans on save (onDidSaveTextDocument). It does not scan files when they are first opened. A user opening a Soroban contract for the first time must either save it or manually run the scan command to see diagnostics.
Current Behavior
File is scanned only on save:
vscode.workspace.onDidSaveTextDocument((doc) => {
if (doc.languageId === 'rust' && runOnSave) {
diagnosticsProvider.scanFile(doc);
}
})
Expected Behavior
Add an optional Scan on Open feature:
- When a Rust file is opened and it has not been scanned yet in this session, automatically scan it
- Add a configuration setting
sorobanGuard.runOnOpen (default: true)
- Track which files have been scanned in a
Set<string> to avoid redundant scans
- Reset the tracking set when the extension is deactivated or when
Clear Results is run
Implementation Notes
- Register
vscode.window.onDidChangeActiveTextEditor to detect when a new file is opened
- Use a
Set<string> of scanned file paths to avoid re-scanning
- Respect the existing exclude patterns
- Show a brief "scanning on open" status in the status bar
- Ensure this does not cause excessive scanning when switching between open tabs
Acceptance Criteria
Complexity
Medium — requires understanding of editor lifecycle events and performance considerations.
Points
150
Description
Currently, the extension only scans on save (
onDidSaveTextDocument). It does not scan files when they are first opened. A user opening a Soroban contract for the first time must either save it or manually run the scan command to see diagnostics.Current Behavior
File is scanned only on save:
Expected Behavior
Add an optional
Scan on Openfeature:sorobanGuard.runOnOpen(default:true)Set<string>to avoid redundant scansClear Resultsis runImplementation Notes
vscode.window.onDidChangeActiveTextEditorto detect when a new file is openedSet<string>of scanned file paths to avoid re-scanningAcceptance Criteria
sorobanGuard.runOnOpencontrols this behaviorComplexity
Medium — requires understanding of editor lifecycle events and performance considerations.
Points
150