@@ -10,6 +10,10 @@ const FOCUS_MODULE_DEPENDENCIES = 'bibimbob.focusModuleDependencies';
1010
1111// Track the current webview panel
1212let currentPanel : vscode . WebviewPanel | undefined = undefined ;
13+ // 전역 변수로 현재 DOT 콘텐츠와 모듈 상태 추적
14+ let currentDotContent : string = '' ;
15+ let currentIsFocusedMode : boolean = false ;
16+ let currentCenterModule : string | undefined = undefined ;
1317
1418export function activate ( context : vscode . ExtensionContext ) {
1519 // console.log('Bibimbob is activated'); // Removed log
@@ -510,6 +514,11 @@ async function runRescriptDep(cliPath: string, args: string[], context?: vscode.
510514
511515// Function to display DOT format graph in webview
512516function showDotGraphWebview ( context : vscode . ExtensionContext , dotContent : string , isFocusedMode : boolean = false , centerModuleName ?: string ) {
517+ // 전역 변수에 현재 상태 저장
518+ currentDotContent = dotContent ;
519+ currentIsFocusedMode = isFocusedMode ;
520+ currentCenterModule = centerModuleName ;
521+
513522 // Detect if the current theme is dark
514523 const isDarkTheme = vscode . window . activeColorTheme && vscode . window . activeColorTheme . kind === vscode . ColorThemeKind . Dark ;
515524
@@ -1249,8 +1258,19 @@ function showDotGraphWebview(context: vscode.ExtensionContext, dotContent: strin
12491258 // Re-render with new data
12501259 renderGraph();
12511260 } else if (message.command === 'updateTheme') {
1252- // Reload the page to apply new theme
1253- window.location.reload();
1261+ // 페이지 새로고침 대신 테마를 적용하고 그래프 재렌더링
1262+ dotSrc = message.dotContent;
1263+ isFocusedMode = message.isFocusedMode;
1264+ centerModule = message.centerModule;
1265+
1266+ // Apply theme changes
1267+ document.documentElement.style.setProperty('--dependents-color',
1268+ message.isDarkTheme ? 'steelblue' : 'lightblue');
1269+ document.documentElement.style.setProperty('--dependencies-color',
1270+ message.isDarkTheme ? 'indianred' : 'lightcoral');
1271+
1272+ // Re-render with new theme
1273+ renderGraph();
12541274 } else if (message.command === 'showError') {
12551275 // Display an error message without rendering graph
12561276 showErrorMessage({ message: message.errorMessage });
@@ -1323,10 +1343,13 @@ function showDotGraphWebview(context: vscode.ExtensionContext, dotContent: strin
13231343 context . subscriptions . push (
13241344 vscode . window . onDidChangeActiveColorTheme ( theme => {
13251345 const newIsDarkTheme = theme . kind === vscode . ColorThemeKind . Dark ;
1326- if ( newIsDarkTheme !== isDarkTheme && currentPanel ) {
1327- // Instead of recreating the webview, just send a message to update theme
1346+ if ( newIsDarkTheme !== isDarkTheme && currentPanel && currentDotContent ) {
1347+ // 웹뷰에 테마 변경 명령 전송 - 페이지 리로드 대신 그래프 재렌더링
13281348 currentPanel . webview . postMessage ( {
13291349 command : 'updateTheme' ,
1350+ dotContent : currentDotContent ,
1351+ isFocusedMode : currentIsFocusedMode ,
1352+ centerModule : currentCenterModule ,
13301353 isDarkTheme : newIsDarkTheme
13311354 } ) ;
13321355 }
0 commit comments