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

Commit

Permalink
Use internal Rustfmt for hover tooltips
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Xanewok committed Aug 16, 2018
1 parent 7a61248 commit 895488d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/actions/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ fn tooltip_struct_enum_union_trait(

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

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

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

let the_type = format_object(fmt.clone(), &fmt_config, decl);
let the_type = format_object(fmt, &fmt_config, decl);
let docs = def_docs(def, &vfs);
let context = None;

Expand Down Expand Up @@ -382,7 +383,8 @@ fn tooltip_function_method(

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

let the_type = || {
def.value
Expand All @@ -394,7 +396,7 @@ fn tooltip_function_method(

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

let the_type = format_method(fmt.clone(), &fmt_config, decl);
let the_type = format_method(fmt, &fmt_config, decl);
let docs = def_docs(def, &vfs);
let context = None;

Expand Down

0 comments on commit 895488d

Please sign in to comment.