Skip to content

Commit 035f492

Browse files
committed
Enhance edge color handling in dependency graph visualization
- Updated edge color processing to differentiate between dependencies and dependents in full mode. - Improved handling of edge colors based on the current theme, ensuring better visibility and user experience. - Refactored logic to streamline color assignment for edges in both focused and full modes.
1 parent 52645b5 commit 035f492

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

vscode-rescriptdep/src/extension.ts

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,8 @@ function showDotGraphWebview(context: vscode.ExtensionContext, dotContent: strin
901901
head.setAttribute('stroke', arrowColor);
902902
});
903903
904-
// 포커스 모드일 때 중앙 모듈 관련 엣지 색상 후처리
905-
if (centerModule) {
904+
// 포커스 모드일 때 중앙 모듈 관련 엣지 색상 처리
905+
if (isFocusedMode && centerModule) {
906906
// 중앙 모듈 노드 식별 (title 텍스트가 중앙 모듈명과 일치)
907907
const centerNode = Array.from(svgElement.querySelectorAll('.node')).find(node => {
908908
const titleEl = node.querySelector('title');
@@ -962,6 +962,55 @@ function showDotGraphWebview(context: vscode.ExtensionContext, dotContent: strin
962962
}
963963
});
964964
}
965+
} else {
966+
// 전체 모드에서 색상 구분 - dependencies(나가는 화살표)와 dependents(들어오는 화살표) 구분
967+
const edges = svgElement.querySelectorAll('.edge');
968+
const visitedNodes = new Set();
969+
970+
// 첫 번째 패스: 모든 노드 이름 수집
971+
edges.forEach(edge => {
972+
const titleEl = edge.querySelector('title');
973+
if (titleEl && titleEl.textContent) {
974+
const titleText = titleEl.textContent;
975+
const parts = titleText.split('->');
976+
if (parts.length === 2) {
977+
const source = parts[0].trim();
978+
const target = parts[1].trim();
979+
visitedNodes.add(source);
980+
visitedNodes.add(target);
981+
}
982+
}
983+
});
984+
985+
// 두 번째 패스: 모든 엣지 색상 수정
986+
edges.forEach(edge => {
987+
const titleEl = edge.querySelector('title');
988+
if (titleEl && titleEl.textContent) {
989+
const titleText = titleEl.textContent;
990+
const parts = titleText.split('->');
991+
if (parts.length === 2) {
992+
const source = parts[0].trim();
993+
const target = parts[1].trim();
994+
995+
// 나가는 화살표는 dependencies 색상
996+
const paths = edge.querySelectorAll('path');
997+
const polygons = edge.querySelectorAll('polygon');
998+
999+
// 다크 테마일 때 더 어두운 색상
1000+
const arrowColor = isDarkTheme ? 'indianred' : 'lightcoral';
1001+
1002+
paths.forEach(path => {
1003+
path.setAttribute('stroke', arrowColor);
1004+
path.setAttribute('stroke-width', '1.2');
1005+
});
1006+
1007+
polygons.forEach(polygon => {
1008+
polygon.setAttribute('fill', arrowColor);
1009+
polygon.setAttribute('stroke', arrowColor);
1010+
});
1011+
}
1012+
}
1013+
});
9651014
}
9661015
9671016
// 초기 viewBox 설정

0 commit comments

Comments
 (0)