Skip to content

Commit 2ae5660

Browse files
rchen152meta-codesync[bot]
authored andcommitted
Show unused-ignore in sandbox
Summary: Modifies the sandbox to check for `unused-ignore` errors when collecting errors. Previously, `unused-ignore` errors never appear in the sandbox regardless of their configured severity. Reviewed By: samwgoldman Differential Revision: D92799376 fbshipit-source-id: 71aa6b69e3a0e95932be765f412fe98967bfc4fb
1 parent 82ce6ae commit 2ae5660

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

pyrefly/lib/playground.rs

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -415,30 +415,29 @@ impl Playground {
415415
let transaction = self.state.transaction();
416416

417417
for (filename, handle) in &self.handles {
418-
let file_errors = transaction
419-
.get_errors([handle])
420-
.collect_errors()
421-
.shown
422-
.into_map(|e| {
423-
let range = e.display_range();
424-
Diagnostic {
425-
start_line: range.start.line_within_file().get() as i32,
426-
start_col: range.start.column().get() as i32,
427-
end_line: range.end.line_within_file().get() as i32,
428-
end_col: range.end.column().get() as i32,
429-
message_header: e.msg_header().to_owned(),
430-
message_details: e.msg_details().unwrap_or("").to_owned(),
431-
kind: e.error_kind().to_name().to_owned(),
432-
// Severity values defined here: https://microsoft.github.io/monaco-editor/typedoc/enums/MarkerSeverity.html
433-
severity: match e.severity() {
434-
Severity::Error => 8,
435-
Severity::Warn => 4,
436-
Severity::Info => 2,
437-
Severity::Ignore => 1,
438-
},
439-
filename: filename.clone(),
440-
}
441-
});
418+
let errors = transaction.get_errors([handle]);
419+
let mut shown = errors.collect_errors().shown;
420+
shown.extend(errors.collect_unused_ignore_errors_for_display().shown);
421+
let file_errors = shown.into_map(|e| {
422+
let range = e.display_range();
423+
Diagnostic {
424+
start_line: range.start.line_within_file().get() as i32,
425+
start_col: range.start.column().get() as i32,
426+
end_line: range.end.line_within_file().get() as i32,
427+
end_col: range.end.column().get() as i32,
428+
message_header: e.msg_header().to_owned(),
429+
message_details: e.msg_details().unwrap_or("").to_owned(),
430+
kind: e.error_kind().to_name().to_owned(),
431+
// Severity values defined here: https://microsoft.github.io/monaco-editor/typedoc/enums/MarkerSeverity.html
432+
severity: match e.severity() {
433+
Severity::Error => 8,
434+
Severity::Warn => 4,
435+
Severity::Info => 2,
436+
Severity::Ignore => 1,
437+
},
438+
filename: filename.clone(),
439+
}
440+
});
442441
all_diagnostics.extend(file_errors);
443442

444443
// Add unused diagnostics

0 commit comments

Comments
 (0)