@@ -7,14 +7,27 @@ import { ThreadTreeProvider } from '../views/ThreadTreeProvider';
77import { AnalysisWebview } from '../views/AnalysisWebview' ;
88import { AnalysisResult } from '../models/types' ;
99
10- let lastResult : AnalysisResult | undefined ;
11-
1210export function registerCommands (
1311 context : vscode . ExtensionContext ,
1412 treeProvider : ThreadTreeProvider ,
1513 output : vscode . OutputChannel ,
1614) : void {
15+ let lastResult : AnalysisResult | undefined ;
1716 const webview = new AnalysisWebview ( context . extensionUri ) ;
17+ context . subscriptions . push ( webview ) ;
18+
19+ // Clear lastResult when editor changes; auto-refresh dashboard on .tdump open
20+ context . subscriptions . push (
21+ vscode . window . onDidChangeActiveTextEditor ( editor => {
22+ lastResult = undefined ;
23+ if ( editor && editor . document . uri . fsPath . endsWith ( '.tdump' ) && webview . isVisible ) {
24+ const text = editor . document . getText ( ) ;
25+ lastResult = analyze ( text , output ) ;
26+ treeProvider . update ( lastResult . dump . threads , editor . document . uri ) ;
27+ webview . update ( lastResult ) ;
28+ }
29+ } ) ,
30+ ) ;
1831
1932 context . subscriptions . push (
2033 vscode . commands . registerCommand ( 'fast-java-thread.analyzeThreadDump' , async ( ) => {
@@ -45,13 +58,10 @@ export function registerCommands(
4558 vscode . commands . registerCommand ( 'fast-java-thread.showDashboard' , ( ) => {
4659 if ( ! lastResult ) {
4760 const editor = vscode . window . activeTextEditor ;
48- if ( editor ) {
61+ if ( editor && editor . document . uri . fsPath . endsWith ( '.tdump' ) ) {
4962 const text = editor . document . getText ( ) ;
5063 lastResult = analyze ( text , output ) ;
5164 treeProvider . update ( lastResult . dump . threads , editor . document . uri ) ;
52- } else {
53- vscode . window . showWarningMessage ( 'No thread dump analyzed yet. Open and analyze a .tdump file first.' ) ;
54- return ;
5565 }
5666 }
5767 webview . show ( lastResult ) ;
@@ -74,6 +84,3 @@ function analyze(text: string, output: vscode.OutputChannel): AnalysisResult {
7484 return { dump, stateGroups, hotMethods, deadlocks } ;
7585}
7686
77- export function getLastResult ( ) : AnalysisResult | undefined {
78- return lastResult ;
79- }
0 commit comments