completion_common.hpp 998 B

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include <string>
  3. #include <vector>
  4. #include <memory>
  5. namespace lumacs {
  6. /// @brief Represents a single completion candidate.
  7. struct CompletionCandidate {
  8. std::string text; ///< The completed text.
  9. std::string display_text; ///< Optional: Text to display to the user (can be richer).
  10. std::string description; ///< Optional: A short description of the candidate.
  11. int score; ///< Matching score (higher is better).
  12. CompletionCandidate(std::string text, int score = 0, std::string display = "", std::string desc = "")
  13. : text(std::move(text)), display_text(std::move(display)), description(std::move(desc)), score(score) {
  14. if (display_text.empty()) {
  15. display_text = this->text;
  16. }
  17. }
  18. bool operator<(const CompletionCandidate& other) const {
  19. if (score != other.score) return score > other.score; // Higher score first
  20. return text < other.text; // Alphabetical for same score
  21. }
  22. };
  23. } // namespace lumacs