-
Notifications
You must be signed in to change notification settings - Fork 347
buf beta lsp formatting duplicates leading comments in file #3423
Copy link
Copy link
Closed
Labels
BugSomething isn't workingSomething isn't working
Description
GitHub repository with your minimal reproducible example (do not fill out this field with "github.com/bufbuild/buf" or we will automatically close your issue, see the instructions above!)
https://github.com/stefanvanburen/buf-repros
Commands
cd ./lsp-duplicate-leading-comments
nvim test.proto
# format the file with the LSPOutput
Results in a duplicate leading comment, diff:
diff --git a/lsp-duplicate-leading-comments/test.proto b/lsp-duplicate-leading-comments/test.proto
index f383f8e..8e97aa1 100644
--- a/lsp-duplicate-leading-comments/test.proto
+++ b/lsp-duplicate-leading-comments/test.proto
@@ -1,4 +1,5 @@
// Leading comment.
+// Leading comment.
syntax = "proto3";
package TODO;Expected Output
No diff.
Anything else?
The issue seems to lie in using the fileNode in the range returned in the TextEdit; the AST doesn't count the leading comments when calculating NodeInfo.Start(), while the formatter touches the entire file.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't working