aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions/keyword.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/completions/keyword.rs')
-rw-r--r--crates/ide_completion/src/completions/keyword.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/crates/ide_completion/src/completions/keyword.rs b/crates/ide_completion/src/completions/keyword.rs
index 0ca97a0e4..ba13d3707 100644
--- a/crates/ide_completion/src/completions/keyword.rs
+++ b/crates/ide_completion/src/completions/keyword.rs
@@ -5,8 +5,8 @@ use std::iter;
5use syntax::{SyntaxKind, T}; 5use syntax::{SyntaxKind, T};
6 6
7use crate::{ 7use crate::{
8 patterns::ImmediateLocation, CompletionContext, CompletionItem, CompletionItemKind, 8 context::PathCompletionContext, patterns::ImmediateLocation, CompletionContext, CompletionItem,
9 CompletionKind, Completions, 9 CompletionItemKind, CompletionKind, Completions,
10}; 10};
11 11
12pub(crate) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) { 12pub(crate) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) {
@@ -128,8 +128,15 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
128 add_keyword("mut", "mut "); 128 add_keyword("mut", "mut ");
129 } 129 }
130 130
131 if ctx.in_loop_body { 131 let (can_be_stmt, in_loop_body) = match ctx.path_context {
132 if ctx.can_be_stmt() { 132 Some(PathCompletionContext {
133 is_trivial_path: true, can_be_stmt, in_loop_body, ..
134 }) => (can_be_stmt, in_loop_body),
135 _ => return,
136 };
137
138 if in_loop_body {
139 if can_be_stmt {
133 add_keyword("continue", "continue;"); 140 add_keyword("continue", "continue;");
134 add_keyword("break", "break;"); 141 add_keyword("break", "break;");
135 } else { 142 } else {
@@ -138,9 +145,6 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
138 } 145 }
139 } 146 }
140 147
141 if !ctx.is_trivial_path() {
142 return;
143 }
144 let fn_def = match &ctx.function_def { 148 let fn_def = match &ctx.function_def {
145 Some(it) => it, 149 Some(it) => it,
146 None => return, 150 None => return,
@@ -148,7 +152,7 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
148 152
149 add_keyword( 153 add_keyword(
150 "return", 154 "return",
151 match (ctx.can_be_stmt(), fn_def.ret_type().is_some()) { 155 match (can_be_stmt, fn_def.ret_type().is_some()) {
152 (true, true) => "return $0;", 156 (true, true) => "return $0;",
153 (true, false) => "return;", 157 (true, false) => "return;",
154 (false, true) => "return $0", 158 (false, true) => "return $0",