Skip to content

Commit f65a1a6

Browse files
committed
fix #685
1 parent b95eae8 commit f65a1a6

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

crates/emmylua_ls/src/handlers/completion/providers/function_provider.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -710,10 +710,6 @@ fn add_str_tpl_ref_completion(
710710
.filter(|type_decl| {
711711
// 检查泛型约束
712712
let current_type = LuaType::Ref(type_decl.get_id());
713-
// 去掉约束自身
714-
if extend_type == current_type {
715-
return false;
716-
}
717713
builder
718714
.semantic_model
719715
.type_check(&extend_type, &current_type)

crates/emmylua_ls/src/handlers/test/completion_test.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,11 @@ mod tests {
643643
kind: CompletionItemKind::ENUM_MEMBER,
644644
..Default::default()
645645
},
646+
VirtualCompletionItem {
647+
label: "\"Component\"".to_string(),
648+
kind: CompletionItemKind::ENUM_MEMBER,
649+
..Default::default()
650+
},
646651
VirtualCompletionItem {
647652
label: "\"D\"".to_string(),
648653
kind: CompletionItemKind::ENUM_MEMBER,
@@ -654,6 +659,44 @@ mod tests {
654659
Ok(())
655660
}
656661

662+
#[test]
663+
fn test_str_tpl_ref_4() {
664+
let mut ws = ProviderVirtualWorkspace::new_with_init_std_lib();
665+
ws.def(
666+
r#"
667+
---@class C: string
668+
669+
---@class D: C
670+
"#,
671+
);
672+
assert!(ws.check_completion_with_kind(
673+
r#"
674+
---@generic T: string
675+
---@param name `T`
676+
---@return T
677+
local function new(name)
678+
return name
679+
end
680+
681+
local a = new(<??>)
682+
"#,
683+
vec![
684+
VirtualCompletionItem {
685+
label: "\"C\"".to_string(),
686+
kind: CompletionItemKind::ENUM_MEMBER,
687+
..Default::default()
688+
},
689+
VirtualCompletionItem {
690+
label: "\"D\"".to_string(),
691+
kind: CompletionItemKind::ENUM_MEMBER,
692+
..Default::default()
693+
},
694+
],
695+
CompletionTriggerKind::TRIGGER_CHARACTER,
696+
));
697+
}
698+
699+
657700
#[gtest]
658701
fn test_table_field_function_1() -> Result<()> {
659702
let mut ws = ProviderVirtualWorkspace::new_with_init_std_lib();

0 commit comments

Comments
 (0)