[clangd] Sort completion results.
Summary:
This is (probably) not required by LSP, but at least one buggy client wants it.
It also simplifies some tests - changed a few completion tests to use -pretty.
Reviewers: hokein, malaperle
Subscribers: ilya-biryukov, cfe-commits
Differential Revision: https://reviews.llvm.org/D39738
llvm-svn: 317670
diff --git a/clang-tools-extra/clangd/ClangdUnit.cpp b/clang-tools-extra/clangd/ClangdUnit.cpp
index 83c97b2..aeeb0e7 100644
--- a/clang-tools-extra/clangd/ClangdUnit.cpp
+++ b/clang-tools-extra/clangd/ClangdUnit.cpp
@@ -389,6 +389,7 @@
assert(CCS && "Expected the CodeCompletionString to be non-null");
Items.push_back(ProcessCodeCompleteResult(Result, *CCS));
}
+ std::sort(Items.begin(), Items.end());
}
GlobalCodeCompletionAllocator &getAllocator() override { return *Allocator; }