Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 2d16f79

Browse files
committed
Make config mutex borrow scope explicit
1 parent a6af35b commit 2d16f79

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/actions/requests.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,16 @@ impl RequestAction for Definition {
201201
let span = ctx.convert_pos_to_span(file_path.clone(), params.position);
202202
let analysis = ctx.analysis.clone();
203203

204-
match analysis.goto_def(&span) {
205-
Ok(out) => {
206-
let result = vec![ls_util::rls_to_location(&out)];
207-
trace!("goto_def (compiler): {:?}", result);
208-
Ok(result)
209-
}
210-
// If analysis failed & `racer_completion` is enabled try racer
211-
_ if ctx.config.lock().unwrap().racer_completion => {
204+
if let Ok(out) = analysis.goto_def(&span) {
205+
let result = vec![ls_util::rls_to_location(&out)];
206+
trace!("goto_def (compiler): {:?}", result);
207+
Ok(result)
208+
} else {
209+
let racer_enabled = {
210+
let config = ctx.config.lock().unwrap();
211+
config.racer_completion
212+
};
213+
if racer_enabled {
212214
let cache = ctx.racer_cache();
213215
let session = ctx.racer_session(&cache);
214216
let location = pos_to_racer_location(params.position);
@@ -220,8 +222,9 @@ impl RequestAction for Definition {
220222

221223
trace!("goto_def (Racer): {:?}", r);
222224
Ok(r)
225+
} else {
226+
Self::fallback_response()
223227
}
224-
_ => Self::fallback_response(),
225228
}
226229
}
227230
}

0 commit comments

Comments
 (0)