Skip to content

Commit c884416

Browse files
committed
fix: update status bar item handling and add message for empty report files
1 parent e442c2f commit c884416

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
# Change Log
1+
# Changelog
22

33
All notable changes to the "magento-log-viewer" extension will be documented in this file.
44

55
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
66

77
## [Unreleased]
88

9+
## [1.7.1] - 2023-10-15
10+
911
### Added
12+
- Added a message when there are no report files.
1013
- Support for Node.js 18.x in GitHub Actions
1114
- Automated tests for releases using GitHub Workflows
1215

16+
### Fixed
17+
- Fixed an issue where the status bar item was being created multiple times.
18+
1319
## [1.7.0] - 2024-12-08
1420

1521
### Added

src/helpers.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ export function updateBadge(treeView: vscode.TreeView<unknown>, logViewerProvide
151151
vscode.commands.executeCommand('setContext', 'magentoLogViewer.hasLogFiles', totalEntries > 0);
152152

153153
// Update status bar item
154-
const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 100);
155-
statusBarItem.text = `Magento Log-Entries: ${totalEntries}`;
156-
statusBarItem.show();
154+
LogViewerProvider.statusBarItem.text = `Magento Log-Entries: ${totalEntries}`;
157155
};
158156

159157
logViewerProvider.onDidChangeTreeData(updateBadgeCount);

src/logViewer.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ import { pathExists, getLineCount, getIconForLogLevel, getLogItems, parseReportT
66
export class LogViewerProvider implements vscode.TreeDataProvider<LogItem>, vscode.Disposable {
77
private _onDidChangeTreeData: vscode.EventEmitter<LogItem | undefined | void> = new vscode.EventEmitter<LogItem | undefined | void>();
88
readonly onDidChangeTreeData: vscode.Event<LogItem | undefined | void> = this._onDidChangeTreeData.event;
9-
private statusBarItem: vscode.StatusBarItem;
9+
public static statusBarItem: vscode.StatusBarItem;
1010
private groupByMessage: boolean;
1111

1212
constructor(private workspaceRoot: string) {
13-
this.statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 100);
14-
this.statusBarItem.command = 'magento-log-viewer.refreshLogFiles';
15-
this.statusBarItem.show();
13+
if (!LogViewerProvider.statusBarItem) {
14+
LogViewerProvider.statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 100);
15+
LogViewerProvider.statusBarItem.command = 'magento-log-viewer.refreshLogFiles';
16+
LogViewerProvider.statusBarItem.show();
17+
}
1618
this.groupByMessage = vscode.workspace.getConfiguration('magentoLogViewer').get<boolean>('groupByMessage', true);
1719
this.updateBadge();
1820
this.updateRefreshButtonVisibility();
@@ -191,11 +193,11 @@ export class LogViewerProvider implements vscode.TreeDataProvider<LogItem>, vsco
191193
const logPath = path.join(this.workspaceRoot, 'var', 'log');
192194
const logFiles = this.getLogFilesWithoutUpdatingBadge(logPath);
193195
const totalEntries = logFiles.reduce((count, file) => count + parseInt(file.description?.match(/\d+/)?.[0] || '0', 10), 0);
194-
this.statusBarItem.text = `Magento Log-Entries: ${totalEntries}`;
196+
LogViewerProvider.statusBarItem.text = `Magento Log-Entries: ${totalEntries}`;
195197
}
196198

197199
dispose() {
198-
this.statusBarItem.dispose();
200+
// Do not dispose the status bar item here to avoid multiple creations
199201
}
200202
}
201203

0 commit comments

Comments
 (0)