Skip to content

Commit 19852da

Browse files
committed
feat: offer action on constant only if one doesn't fully annotated
1 parent 70b0c76 commit 19852da

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

compiler-core/src/language_server/code_action.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,8 +1386,8 @@ impl<'a> AnnotateTopLevelDefinitions<'a> {
13861386
pub fn code_actions(mut self) -> Vec<CodeAction> {
13871387
self.visit_typed_module(&self.module.ast);
13881388

1389-
// We only want to trigger the action if we're over one of the definition in
1390-
// the module
1389+
// We only want to trigger the action if we're over one of the definition
1390+
// which is lacking some annotations in the module
13911391
if !self.is_hovering_definition || self.edits.edits.is_empty() {
13921392
return vec![];
13931393
};
@@ -1406,15 +1406,16 @@ impl<'ast> ast::visit::Visit<'ast> for AnnotateTopLevelDefinitions<'_> {
14061406
fn visit_typed_module_constant(&mut self, constant: &'ast TypedModuleConstant) {
14071407
let code_action_range = self.edits.src_span_to_lsp_range(constant.location);
14081408

1409-
if overlaps(code_action_range, self.params.range) {
1410-
self.is_hovering_definition = true;
1411-
}
1412-
14131409
// We don't need to add an annotation if there already is one
14141410
if constant.annotation.is_some() {
14151411
return;
14161412
}
14171413

1414+
// We're hovering definition which needs some annotations
1415+
if overlaps(code_action_range, self.params.range) {
1416+
self.is_hovering_definition = true;
1417+
}
1418+
14181419
self.edits.insert(
14191420
constant.name_location.end,
14201421
format!(

0 commit comments

Comments
 (0)