completion#308
Closed
xuhuanzy wants to merge 4 commits into
Closed
Conversation
Contributor
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #272