Initial commit of highlight related configuration w/ implementation.

This commit is contained in:
Kevin DeLorey
2021-07-21 19:44:16 -06:00
parent 1dd1814100
commit b75e0e7bb1
6 changed files with 78 additions and 10 deletions

View File

@@ -11,8 +11,8 @@ use std::{ffi::OsString, iter, path::PathBuf};
use flycheck::FlycheckConfig;
use ide::{
AssistConfig, CompletionConfig, DiagnosticsConfig, HoverConfig, HoverDocFormat,
InlayHintsConfig, JoinLinesConfig,
AssistConfig, CompletionConfig, DiagnosticsConfig, HighlightRelatedConfig, HoverConfig,
HoverDocFormat, InlayHintsConfig, JoinLinesConfig,
};
use ide_db::helpers::{
insert_use::{ImportGranularity, InsertUseConfig, PrefixKind},
@@ -261,6 +261,14 @@ config_data! {
workspace_symbol_search_scope: WorskpaceSymbolSearchScopeDef = "\"workspace\"",
/// Workspace symbol search kind.
workspace_symbol_search_kind: WorskpaceSymbolSearchKindDef = "\"only_types\"",
highlightRelated_references: bool = "true",
highlightRelated_exitPoints: bool = "true",
highlightRelated_breakPoints: bool = "true",
highlightRelated_yieldPoints: bool = "true",
}
}
@@ -852,6 +860,15 @@ impl Config {
false
)
}
pub fn highlight_related(&self) -> HighlightRelatedConfig {
HighlightRelatedConfig {
references: self.data.highlightRelated_references,
break_points: self.data.highlightRelated_breakPoints,
exit_points: self.data.highlightRelated_exitPoints,
yield_points: self.data.highlightRelated_yieldPoints,
}
}
}
#[derive(Deserialize, Debug, Clone)]

View File

@@ -1188,7 +1188,7 @@ pub(crate) fn handle_document_highlight(
let position = from_proto::file_position(&snap, params.text_document_position_params)?;
let line_index = snap.file_line_index(position.file_id)?;
let refs = match snap.analysis.highlight_related(position)? {
let refs = match snap.analysis.highlight_related(snap.config.highlight_related(), position)? {
None => return Ok(None),
Some(refs) => refs,
};