Skip to content

Commit

Permalink
bugfix: Don't set empty edits
Browse files Browse the repository at this point in the history
It seems that the command will not be invoked in such editors such as Zed in this case

Fixes #6949
  • Loading branch information
tgodzik committed Nov 21, 2024
1 parent d1fce17 commit 29c783a
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ object CodeActionBuilder {
"Only changes or documentChanges can be set in code action at the same time",
)

val workspaceEdits = new l.WorkspaceEdit()
if (changes.nonEmpty)
// we don't want to set edit to make it resolve lazily in codeAction/resolve
if (changes.nonEmpty) {
val workspaceEdits = new l.WorkspaceEdit()
workspaceEdits.setChanges(
changes
.map { case (path, edits) =>
Expand All @@ -37,10 +38,12 @@ object CodeActionBuilder {
.toMap
.asJava
)
else if (documentChanges.nonEmpty)
codeAction.setEdit(workspaceEdits)
} else if (documentChanges.nonEmpty) {
val workspaceEdits = new l.WorkspaceEdit()
workspaceEdits.setDocumentChanges(documentChanges.map(_.asJava).asJava)

codeAction.setEdit(workspaceEdits)
codeAction.setEdit(workspaceEdits)
}
command.foreach(codeAction.setCommand)
disabledReason.foreach(reason =>
codeAction.setDisabled(new l.CodeActionDisabled(reason))
Expand Down

0 comments on commit 29c783a

Please sign in to comment.