microsoft / sarif-vscode-extension

SARIF Microsoft Visual Studio Code extension
MIT License
110 stars 49 forks source link

Opening more than two files shows repeated results #564

Open mzyKi opened 4 months ago

mzyKi commented 4 months ago

I use API like this in my vscode extension:

export async function openSarifViewerPannel(filePath: string) {
  const sarifExt = extensions.getExtension('MS-SarifVSCode.sarif-viewer');
  if (sarifExt === undefined) {
    vscode.window
        .showWarningMessage(
            'Please install \'Sarif Viewer\' to view SAST report better.',
            ...['Install'])
        .then(install => {
          if (install === 'Install') {
            commands.executeCommand(
                'workbench.extensions.installExtension',
                'MS-SarifVSCode.sarif-viewer');
          }
        });
    return false;
  }

  if (!sarifExt.isActive) await sarifExt.activate();
  await sarifExt.exports.openLogs([
    Uri.file(filePath),
  ]);
  return true;
}

// ...
          XXX.openSarifViewerPannel(sarifFilePath);
          XXX.openSarifViewerPannel(sarifFilePath2);
          XXX.openSarifViewerPannel(sarifFilePath3);
//...

It shows result that first give one log , and the other two double opened give me two logs. I debug about this only find openLogs executed three times. I am not sure whether my usage is compliant.Thanks for your suggestions.

The result like the following:

image

sarif-viewer version v3.4.4

jsoref commented 2 months ago

This appears to be non-compliant:

https://github.com/microsoft/sarif-vscode-extension/blob/a9c086079c90af39bfa7b4572550507fae24e3d9/src/extension/index.d.ts#L12-L16

mzyKi commented 2 months ago

This appears to be non-compliant:

https://github.com/microsoft/sarif-vscode-extension/blob/a9c086079c90af39bfa7b4572550507fae24e3d9/src/extension/index.d.ts#L12-L16

Thanks for your response.But I am not familiar with typescript.I can not fix this bug.

jsoref commented 2 months ago

You should call closeLogs() at times, otherwise you'll accumulate things.