Skip to content

Commit

Permalink
Show code actions only when there are issues reported.
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig committed Nov 11, 2022
1 parent ef7a5a2 commit 4fb3bbd
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions bundled/tool/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def update_sys_path(path_to_add: str, strategy: str) -> None:
RUNNER = pathlib.Path(__file__).parent / "runner.py"

MAX_WORKERS = 5
LSP_SERVER = server.LanguageServer(max_workers=MAX_WORKERS)
LSP_SERVER = server.LanguageServer(
name="isort-server", version="v0.1.0", max_workers=MAX_WORKERS
)


# **********************************************************
Expand Down Expand Up @@ -242,15 +244,16 @@ def code_action_organize_imports(params: lsp.CodeActionParams):
for d in params.context.diagnostics
if d.source == "isort" and d.code == "E"
]
actions.append(
lsp.CodeAction(
title="isort: Fix import sorting and/or formatting",
kind=lsp.CodeActionKind.QuickFix,
data=params.text_document.uri,
edit=None,
diagnostics=diagnostics,
),
)
if diagnostics:
actions.append(
lsp.CodeAction(
title="isort: Fix import sorting and/or formatting",
kind=lsp.CodeActionKind.QuickFix,
data=params.text_document.uri,
edit=None,
diagnostics=diagnostics,
),
)

return actions if actions else None

Expand Down

0 comments on commit 4fb3bbd

Please sign in to comment.