Skip to content

Commit 0bd5c30

Browse files
committed
hover function return remove nil
1 parent 6d9759b commit 0bd5c30

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

crates/emmylua_ls/src/handlers/hover/hover_humanize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ fn build_signature_rets(
351351
overload_rets_string
352352
} else {
353353
let rets = &signature.return_docs;
354-
if rets.is_empty() {
354+
if rets.is_empty() || signature.get_return_type().is_nil() {
355355
"".to_string()
356356
} else {
357357
format!(
@@ -372,7 +372,7 @@ fn build_signature_rets(
372372
overload_rets_string
373373
} else {
374374
let rets = &signature.return_docs;
375-
if rets.is_empty() {
375+
if rets.is_empty() || signature.get_return_type().is_nil() {
376376
"".to_string()
377377
} else {
378378
let mut rets_string_multiline = String::new();

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,23 @@ mod tests {
163163
},
164164
));
165165
}
166+
167+
#[test]
168+
fn test_4() {
169+
let mut ws = ProviderVirtualWorkspace::new();
170+
assert!(ws.check_hover(
171+
r#"
172+
---@class ClosureTest
173+
---@field e fun(a: string, b: number)
174+
local Test
175+
176+
function Test.<??>e(a, b)
177+
A = a
178+
end
179+
"#,
180+
VirtualHoverResult {
181+
value: "\n```lua\nfunction ClosureTest.e(a: string, b: number)\n```\n\n---\n\n---\n\n```lua\n(field) ClosureTest.e(a: string, b: number)\n```\n".to_string(),
182+
},
183+
));
184+
}
166185
}

0 commit comments

Comments
 (0)