Skip to content

Commit f1f0c0c

Browse files
committed
optimize local var hint
1 parent eee5b44 commit f1f0c0c

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

crates/emmylua_ls/src/handlers/inlay_hint/build_function_hint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn get_part(semantic_model: &SemanticModel, typ: &LuaType) -> Option<InlayHintLa
147147

148148
fn get_type_location(semantic_model: &SemanticModel, typ: &LuaType) -> Option<Location> {
149149
match typ {
150-
LuaType::Ref(id) => {
150+
LuaType::Ref(id) | LuaType::Def(id) => {
151151
let type_decl = semantic_model
152152
.get_db()
153153
.get_type_index()

crates/emmylua_ls/src/handlers/inlay_hint/build_inlay_hint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ fn build_local_name_hint(
347347
position: lsp_range.end,
348348
text_edits: None,
349349
tooltip: None,
350-
padding_left: Some(true),
350+
padding_left: None,
351351
padding_right: None,
352352
data: None,
353353
};

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,19 @@ mod tests {
108108
.unwrap();
109109
assert!(result.len() == 4);
110110
}
111+
112+
#[test]
113+
fn test_class_def_var_hint() {
114+
let mut ws = ProviderVirtualWorkspace::new();
115+
let result = ws
116+
.check_inlay_hint(
117+
r#"
118+
---@class Hint.1
119+
---@overload fun(a: integer): Hint.1
120+
local Hint1
121+
"#,
122+
)
123+
.unwrap();
124+
assert!(result.len() == 1);
125+
}
111126
}

0 commit comments

Comments
 (0)