Skip to content

Commit

Permalink
ADd messages
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Dec 31, 2022
1 parent 7259d0b commit 8275a70
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions ruff_lsp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ class Location(TypedDict):

class Fix(TypedDict):
content: str
message: str | None
location: Location
end_location: Location

Expand Down Expand Up @@ -388,13 +389,19 @@ def code_action(params: CodeActionParams) -> list[CodeAction] | None:
for diagnostic in params.context.diagnostics:
if diagnostic.source == "Ruff":
if diagnostic.data is not None:
fix = cast(Fix, diagnostic.data)

title: str
if fix.get("message"):
title = f"Ruff: {fix['message']}"
elif diagnostic.code:
title = f"Ruff: Fix {diagnostic.code}"
else:
title = "Ruff: Autofix"

actions.append(
CodeAction(
title=(
f"Ruff: Fix {diagnostic.code}"
if diagnostic.code
else "Ruff: Fix"
),
title=title,
kind=CodeActionKind.QuickFix,
data=params.text_document.uri,
edit=_create_workspace_edit(
Expand Down

0 comments on commit 8275a70

Please sign in to comment.