-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix graph issue when deleting node #401
Changes from all commits
0d6f819
d7443ff
7f191d0
2a1d676
c85e035
1365985
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ function getStyle(name, fallback) { | |
|
||
const style = { | ||
background: getStyle(`--vscode-panel-background`, "#202020"), | ||
fontSize: parseInt(getStyle(`--vscode-font-size`, 12)), | ||
fontSize: parseInt(getStyle(`--vscode-font-size`, 12)) - 2, | ||
highlightedForeground: getStyle( | ||
"--vscode-list-highlightForeground", | ||
"#f9c74f" | ||
|
@@ -27,7 +27,7 @@ const style = { | |
const sizeScale = d3 | ||
.scaleLinear() | ||
.domain([0, 30]) | ||
.range([1, 3]) | ||
.range([0.5, 2]) | ||
.clamp(true); | ||
|
||
const labelAlpha = d3 | ||
|
@@ -97,6 +97,12 @@ const Actions = { | |
}); | ||
m.data.links = links; // links can be swapped out without problem | ||
|
||
// check that selected/hovered nodes are still valid (see #397) | ||
m.hoverNode = remaining.has(m.hoverNode) ? m.hoverNode : null; | ||
m.selectedNodes = new Set( | ||
Array.from(m.selectedNodes).filter(nId => remaining.has(nId)) | ||
); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I rebased my branch for #394 on top of this -- I'm noticing that when I save a file the graph loses track of which node is selected / being hovered over. Could that be related to my change of not deleting the node anymore on save? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just reproduced this on master, so it's unrelated to your changes - I am investigating what's causing this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you rebase from master the issue is now fixed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
// annoying we need to call this function, but I haven't found a good workaround | ||
graph.graphData(m.data); | ||
}), | ||
|
@@ -124,7 +130,7 @@ function initDataviz(channel) { | |
.d3Force("x", d3.forceX()) | ||
.d3Force("y", d3.forceY()) | ||
.d3Force("collide", d3.forceCollide(graph.nodeRelSize())) | ||
.linkWidth(0.5) | ||
.linkWidth(0.2) | ||
.linkDirectionalParticles(1) | ||
.linkDirectionalParticleWidth(link => | ||
getLinkState(link, model) === "highlighted" ? 1 : 0 | ||
|
@@ -142,7 +148,7 @@ function initDataviz(channel) { | |
const label = info.title; | ||
|
||
Draw(ctx) | ||
.circle(node.x, node.y, size + 0.5, border) | ||
.circle(node.x, node.y, size + 0.2, border) | ||
.circle(node.x, node.y, size, fill) | ||
.text(label, node.x, node.y + size + 1, fontSize, textColor); | ||
}) | ||
|
@@ -260,6 +266,19 @@ try { | |
type: "webviewDidLoad" | ||
}); | ||
}; | ||
window.addEventListener("error", error => { | ||
vscode.postMessage({ | ||
type: "error", | ||
payload: { | ||
message: error.message, | ||
filename: error.filename, | ||
lineno: error.lineno, | ||
colno: error.colno, | ||
error: error.error | ||
} | ||
}); | ||
}); | ||
|
||
window.addEventListener("message", event => { | ||
const message = event.data; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick for the future, changes like these add noise to the original PR
I also suffer from this but I think we can all each other get better