mirror of https://github.com/astral-sh/ruff
[`playground`] Allow hover quick fixes to appear for overlapping diagnostics (#20527)
This commit is contained in:
parent
edb920b4d5
commit
2c916562ba
|
|
@ -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,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue