Skip to content

Commit 547caf1

Browse files
committed
Fix export error handling and deprecated API usage
1 parent 7314c49 commit 547caf1

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to the Go Memory Layout Visualizer extension will be documented in this file.
44

5+
## [0.2.1] - 2025-11-26
6+
7+
### Fixed
8+
9+
- Added error handling for file export operations
10+
- Fixed deprecated `workspace.rootPath` usage, now uses `workspaceFolders`
11+
- Export success message no longer exposes full file path
12+
513
## [0.2.0] - 2025-11-23
614

715
### Added

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "go-memory-visualizer",
33
"displayName": "Go Memory Layout Visualizer",
44
"description": "Real-time visualization of Go struct memory layout, padding, and alignment with optimization suggestions",
5-
"version": "0.2.0",
5+
"version": "0.2.1",
66
"publisher": "RhinoSoftware",
77
"author": {
88
"name": "RhinoSoftware"

src/extension.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,16 +323,22 @@ async function exportLayoutCommand(parser: GoParser) {
323323
}
324324

325325
const defaultFileName = `memory-layout-${currentArch}-${Date.now()}.${extension}`;
326+
const workspaceFolder = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath || '';
327+
326328
const uri = await vscode.window.showSaveDialog({
327-
defaultUri: vscode.Uri.file(path.join(vscode.workspace.rootPath || '', defaultFileName)),
329+
defaultUri: vscode.Uri.file(path.join(workspaceFolder, defaultFileName)),
328330
filters: {
329-
[format]: [extension]
331+
'Memory Layout': [extension]
330332
}
331333
});
332334

333335
if (uri) {
334-
fs.writeFileSync(uri.fsPath, content);
335-
vscode.window.showInformationMessage(`Memory layout exported to ${uri.fsPath}`);
336+
try {
337+
fs.writeFileSync(uri.fsPath, content);
338+
vscode.window.showInformationMessage(`Memory layout exported successfully`);
339+
} catch (error) {
340+
vscode.window.showErrorMessage(`Export failed: ${(error as Error).message}`);
341+
}
336342
}
337343
}
338344

0 commit comments

Comments
 (0)