Skip to content

completion#308

Closed
xuhuanzy wants to merge 4 commits into
EmmyLuaLs:mainfrom
xuhuanzy:completion
Closed

completion#308
xuhuanzy wants to merge 4 commits into
EmmyLuaLs:mainfrom
xuhuanzy:completion

Conversation

@xuhuanzy
Copy link
Copy Markdown
Member

@xuhuanzy xuhuanzy commented Mar 31, 2025

fixes #272

@CppCXY CppCXY requested a review from Copilot March 31, 2025 12:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances and refactors the completion functionality by adding new tests and updating various providers to improve trigger handling and member completion behavior.

  • New tests in completion_test.rs validate different completion scenarios.
  • Providers such as function_provider, table_field_provider, and env_provider are refactored to improve trigger checks and output ordering.
  • The completion builder now tracks whether a completion was triggered by a space character.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/emmylua_ls/src/handlers/completion/test/completion_test.rs Added new tests for various completion scenarios
crates/emmylua_ls/src/handlers/completion/providers/table_field_provider.rs Introduced a helper (check_can_add_completion) to prevent completions after comment tokens
crates/emmylua_ls/src/handlers/completion/providers/mod.rs Replaced type_special_provider with function_provider to adjust provider priority
crates/emmylua_ls/src/handlers/completion/providers/function_provider.rs Refactored token handling and enhanced enum members ordering
crates/emmylua_ls/src/handlers/completion/providers/env_provider.rs Updated trigger check logic to use check_can_add_completion for environment-based completions
crates/emmylua_ls/src/handlers/completion/completion_builder.rs Added is_space_trigger_character field and associated logic during builder initialization
Comments suppressed due to low confidence (1)

crates/emmylua_ls/src/handlers/completion/completion_builder.rs:28

  • [nitpick] Review the logic for determining is_space_trigger_character to ensure that all whitespace cases are handled as intended, as reliance on trim_end().is_empty() may not cover all edge cases.
let is_space_trigger_character = if trigger_kind == CompletionTriggerKind::TRIGGER_CHARACTER { trigger_token.text().trim_end().is_empty() } else { false };

Comment on lines +43 to +45
fn check_can_add_completion(builder: &CompletionBuilder) -> Option<()> {
if builder.is_space_trigger_character {
return None;
Copy link

Copilot AI Mar 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check_can_add_completion function in this file returns an Option<()> while a similar helper in table_field_provider returns a bool. Consider unifying their signatures to maintain consistency across providers.

Suggested change
fn check_can_add_completion(builder: &CompletionBuilder) -> Option<()> {
if builder.is_space_trigger_character {
return None;
fn check_can_add_completion(builder: &CompletionBuilder) -> bool {
if builder.is_space_trigger_character {
return false;

Copilot uses AI. Check for mistakes.
@xuhuanzy xuhuanzy closed this Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overriding fields in subclass results in completion results from superclass still showing up

2 participants