[`playground`] Allow hover quick fixes to appear for overlapping diagnostics (#20527)

This commit is contained in:
Dan Parizher 2025-09-23 09:15:31 -04:00 committed by GitHub
parent edb920b4d5
commit 2c916562ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 1 deletions

View File

@ -124,7 +124,18 @@ class RuffCodeActionProvider implements CodeActionProvider {
range: Range, range: Range,
): languages.ProviderResult<languages.CodeActionList> { ): languages.ProviderResult<languages.CodeActionList> {
const actions = this.diagnostics const actions = this.diagnostics
.filter((check) => range.startLineNumber === check.start_location.row) // Show fixes for any diagnostic whose range intersects the requested range
.filter((check) =>
Range.areIntersecting(
new Range(
check.start_location.row,
check.start_location.column,
check.end_location.row,
check.end_location.column,
),
range,
),
)
.filter(({ fix }) => fix) .filter(({ fix }) => fix)
.map((check) => ({ .map((check) => ({
title: check.fix title: check.fix
@ -173,6 +184,7 @@ function updateMarkers(monaco: Monaco, diagnostics: Array<Diagnostic>) {
model, model,
"owner", "owner",
diagnostics.map((diagnostic) => ({ diagnostics.map((diagnostic) => ({
code: diagnostic.code ?? undefined,
startLineNumber: diagnostic.start_location.row, startLineNumber: diagnostic.start_location.row,
startColumn: diagnostic.start_location.column, startColumn: diagnostic.start_location.column,
endLineNumber: diagnostic.end_location.row, endLineNumber: diagnostic.end_location.row,