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

Commit 454d013

Browse files
committed
Use internal Rustfmt for hover tooltips
External ones have to create temporary files to pass configs and whatnot and we can technically issue a lot of these hover requests fast - these will be short and the exact formatting does not matter, so we'll just use the internal one instead.
1 parent 1f0db35 commit 454d013

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/actions/hover.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ fn tooltip_struct_enum_union_trait(
328328

329329
let vfs = ctx.vfs.clone();
330330
let fmt_config = ctx.fmt_config();
331-
let fmt = ctx.formatter();
331+
// We hover often so use the in-process one to speed things up
332+
let fmt = Rustfmt::Internal;
332333

333334
// fallback in case source extration fails
334335
let the_type = || match def.kind {
@@ -341,7 +342,7 @@ fn tooltip_struct_enum_union_trait(
341342

342343
let decl = def_decl(def, &vfs, the_type);
343344

344-
let the_type = format_object(fmt.clone(), &fmt_config, decl);
345+
let the_type = format_object(fmt, &fmt_config, decl);
345346
let docs = def_docs(def, &vfs);
346347
let context = None;
347348

@@ -382,7 +383,8 @@ fn tooltip_function_method(
382383

383384
let vfs = ctx.vfs.clone();
384385
let fmt_config = ctx.fmt_config();
385-
let fmt = ctx.formatter();
386+
// We hover often so use the in-process one to speed things up
387+
let fmt = Rustfmt::Internal;
386388

387389
let the_type = || {
388390
def.value
@@ -394,7 +396,7 @@ fn tooltip_function_method(
394396

395397
let decl = def_decl(def, &vfs, the_type);
396398

397-
let the_type = format_method(fmt.clone(), &fmt_config, decl);
399+
let the_type = format_method(fmt, &fmt_config, decl);
398400
let docs = def_docs(def, &vfs);
399401
let context = None;
400402

0 commit comments

Comments
 (0)