Merge pull request #2297 from kiljacken/master

Add fancy truncation of type hints.
This commit is contained in:
Aleksey Kladov 2019-11-20 08:38:25 +03:00 committed by GitHub
commit eec68e6f45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 134 additions and 35 deletions

View file

@ -29,6 +29,8 @@ pub struct ServerConfig {
pub lru_capacity: Option<usize>,
pub max_inlay_hint_length: Option<usize>,
/// For internal usage to make integrated tests faster.
#[serde(deserialize_with = "nullable_bool_true")]
pub with_sysroot: bool,
@ -44,6 +46,7 @@ impl Default for ServerConfig {
exclude_globs: Vec::new(),
use_client_watching: false,
lru_capacity: None,
max_inlay_hint_length: None,
with_sysroot: true,
feature_flags: FxHashMap::default(),
}

View file

@ -123,6 +123,7 @@ pub fn main_loop(
.and_then(|it| it.folding_range.as_ref())
.and_then(|it| it.line_folding_only)
.unwrap_or(false),
max_inlay_hint_length: config.max_inlay_hint_length,
}
};

View file

@ -888,7 +888,7 @@ pub fn handle_inlay_hints(
let analysis = world.analysis();
let line_index = analysis.file_line_index(file_id)?;
Ok(analysis
.inlay_hints(file_id)?
.inlay_hints(file_id, world.options.max_inlay_hint_length)?
.into_iter()
.map(|api_type| InlayHint {
label: api_type.label.to_string(),

View file

@ -28,6 +28,7 @@ pub struct Options {
pub publish_decorations: bool,
pub supports_location_link: bool,
pub line_folding_only: bool,
pub max_inlay_hint_length: Option<usize>,
}
/// `WorldState` is the primary mutable state of the language server