Skip to content

Commit 1550377

Browse files
committed
fix hover field function
1 parent f99c3de commit 1550377

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

crates/emmylua_code_analysis/src/compilation/analyzer/doc/field_or_operator_def_tags.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ pub fn analyze_field(analyzer: &mut DocAnalyzer, tag: LuaDocTagField) -> Option<
144144
}
145145

146146
if !description.is_empty() {
147+
// 不需要传入`owner`, 当前`owner`的效果是判断是否为`signature`, 如果是则不移除`['#', '@']`首字符
148+
// 但以`field`定义的必须移除首字符
149+
let description = preprocess_description(&description, None);
147150
analyzer.db.get_property_index_mut().add_description(
148151
analyzer.file_id,
149152
property_owner.clone(),

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,4 +501,21 @@ mod tests {
501501
},
502502
));
503503
}
504+
505+
#[test]
506+
fn test_field_remove_first() {
507+
let mut ws = ProviderVirtualWorkspace::new();
508+
assert!(ws.check_hover(
509+
r#"
510+
---@class A<T>
511+
---@field next fun(value: T) # 测试
512+
local A = {}
513+
514+
A.<??>next()
515+
"#,
516+
VirtualHoverResult {
517+
value: "```lua\n(field) A.next(value: T)\n```\n\n---\n\n测试".to_string(),
518+
},
519+
));
520+
}
504521
}

0 commit comments

Comments
 (0)