Skip to content

Commit 4e9489f

Browse files
authored
fix: sas log code action should not impact others (#1308)
1 parent 4cfbc7c commit 4e9489f

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

client/src/components/logViewer/DiagnosticCodeActionProvider.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
CodeActionKind,
77
CodeActionProvider,
88
Command,
9+
Diagnostic,
910
DiagnosticSeverity,
1011
ProviderResult,
1112
Range,
@@ -14,7 +15,7 @@ import {
1415
l10n,
1516
} from "vscode";
1617

17-
import { sasDiagnostic } from "./sasDiagnostics";
18+
import { diagnosticSource, sasDiagnostic } from "./sasDiagnostics";
1819

1920
export class DiagnosticCodeActionProvider implements CodeActionProvider {
2021
public static readonly providedCodeActionKinds = [CodeActionKind.QuickFix];
@@ -23,37 +24,40 @@ export class DiagnosticCodeActionProvider implements CodeActionProvider {
2324
_range: Range | Selection,
2425
context: CodeActionContext,
2526
): ProviderResult<(CodeAction | Command)[]> {
26-
if (context.diagnostics.length === 0) {
27+
const diagnostics = context.diagnostics.filter(
28+
(diagnostic) => diagnostic.source === diagnosticSource,
29+
);
30+
if (diagnostics.length === 0) {
2731
return [];
2832
}
2933

3034
return [
3135
this.createCodeAction(
3236
document,
33-
context,
37+
diagnostics,
3438
sasDiagnostic.DiagnosticCommands.IgnoreCommand,
3539
),
3640
this.createCodeAction(
3741
document,
38-
context,
42+
diagnostics,
3943
sasDiagnostic.DiagnosticCommands.IgnoreAllWarningCommand,
4044
),
4145
this.createCodeAction(
4246
document,
43-
context,
47+
diagnostics,
4448
sasDiagnostic.DiagnosticCommands.IgnoreAllErrorCommand,
4549
),
4650
this.createCodeAction(
4751
document,
48-
context,
52+
diagnostics,
4953
sasDiagnostic.DiagnosticCommands.IgnoreAllCommand,
5054
),
5155
];
5256
}
5357

5458
private createCodeAction(
5559
document: TextDocument,
56-
context: CodeActionContext,
60+
diagnostics: Diagnostic[],
5761
command: string,
5862
): CodeAction {
5963
const action = new CodeAction("", CodeActionKind.QuickFix);
@@ -64,7 +68,7 @@ export class DiagnosticCodeActionProvider implements CodeActionProvider {
6468
action.command = {
6569
command: command,
6670
title: l10n.t("Ignore: current position"),
67-
arguments: [context.diagnostics, document.uri],
71+
arguments: [diagnostics, document.uri],
6872
};
6973
break;
7074
case sasDiagnostic.DiagnosticCommands.IgnoreAllWarningCommand:

client/src/components/logViewer/sasDiagnostics.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import { DiagnosticCodeActionProvider } from "./DiagnosticCodeActionProvider";
2222
import { Problem } from "./ProblemProcessor";
2323
import { parseLog } from "./logParser";
2424

25+
export const diagnosticSource = "sas log";
26+
2527
let diagnosticCollection: DiagnosticCollection;
2628

2729
enum DiagnosticCommands {
@@ -120,7 +122,7 @@ function constructDiagnostics(problems: Problem[]): Diagnostic[] {
120122
message,
121123
type === "error" ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning,
122124
);
123-
diagnostic.source = "sas log";
125+
diagnostic.source = diagnosticSource;
124126
return diagnostic;
125127
});
126128

0 commit comments

Comments
 (0)