Skip to content

Commit

Permalink
fix: dataflow links work across files (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
teodora-sandu authored Jun 17, 2024
1 parent 7f32912 commit ae111dd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Snyk Security Changelog

## [2.12.2]
- update to LS protocol version 12
- Refactors the feature flag logic into its own service.
- Fix multi-file links in the DataFlow HTML panel.

## [2.12.1]
- Fix applying AI fixes on Windows.
- Add CSS rules for `.light-only` and `.dark-only` to the LSP implementation. This allows the LSP to apply different styles based on the current theme.
- Update to LS protocol version 12.

## [2.12.0]
- Fix Code Suggestion rendering issue on Windows.
Expand Down
28 changes: 16 additions & 12 deletions src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,10 @@
vscode.postMessage(message);
}

function navigateToIssue(i: number) {
function navigateToIssue(position?: MarkerPosition) {
if (!suggestion) {
return;
}
const markers = suggestion.markers;
if (!markers) {
return;
}
const position = {
file: suggestion.filePath,
rows: markers[i].pos[0].rows,
cols: markers[i].pos[0].cols,
};

const message: OpenLocalMessage = {
type: 'openLocal',
Expand Down Expand Up @@ -175,7 +166,20 @@
const dataFlows = document.getElementsByClassName('data-flow-clickable-row');
for (let i = 0; i < dataFlows.length; i++) {
dataFlows[i].addEventListener('click', () => {
navigateToIssue(i);
const rows: Point = [
parseInt(dataFlows[i].getAttribute('start-line')!),
parseInt(dataFlows[i].getAttribute('end-line')!),
];
const cols: Point = [
parseInt(dataFlows[i].getAttribute('start-character')!),
parseInt(dataFlows[i].getAttribute('end-character')!),
];
const position = {
file: dataFlows[i].getAttribute('file-path')!,
rows: rows,
cols: cols,
};
navigateToIssue(position);
});
}
document.getElementById('ignore-line-issue')?.addEventListener('click', () => {
Expand All @@ -185,7 +189,7 @@
ignoreIssue(false);
});
document.getElementById('position-line')!.addEventListener('click', () => {
navigateToIssue(0);
navigateToIssue();
});

function toggleElement(element: Element | null, toggle: 'hide' | 'show') {
Expand Down

0 comments on commit ae111dd

Please sign in to comment.