Skip to content

Commit a7b6175

Browse files
committed
Declare joinLines_* as local
1 parent 451a406 commit a7b6175

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,6 @@ config_data! {
391391
/// Enables the experimental support for interpreting tests.
392392
interpret_tests: bool = "false",
393393

394-
/// Join lines merges consecutive declaration and initialization of an assignment.
395-
joinLines_joinAssignments: bool = "true",
396-
/// Join lines inserts else between consecutive ifs.
397-
joinLines_joinElseIf: bool = "true",
398-
/// Join lines removes trailing commas.
399-
joinLines_removeTrailingComma: bool = "true",
400-
/// Join lines unwraps trivial blocks.
401-
joinLines_unwrapTrivialBlock: bool = "true",
402394

403395

404396
/// Whether to show `Debug` lens. Only applies when
@@ -571,6 +563,16 @@ config_data! {
571563
imports_prefer_no_std: bool = "false",
572564
/// The path structure for newly inserted paths to use.
573565
imports_prefix: ImportPrefixDef = "\"plain\"",
566+
567+
568+
/// Join lines merges consecutive declaration and initialization of an assignment.
569+
joinLines_joinAssignments: bool = "true",
570+
/// Join lines inserts else between consecutive ifs.
571+
joinLines_joinElseIf: bool = "true",
572+
/// Join lines removes trailing commas.
573+
joinLines_removeTrailingComma: bool = "true",
574+
/// Join lines unwraps trivial blocks.
575+
joinLines_unwrapTrivialBlock: bool = "true",
574576
}
575577
}
576578

@@ -719,6 +721,15 @@ impl<'a> LocalConfigView<'a> {
719721
fn experimental(&self, index: &'static str) -> bool {
720722
try_or_def!(self.caps.experimental.as_ref()?.get(index)?.as_bool()?)
721723
}
724+
725+
pub fn join_lines(&self) -> JoinLinesConfig {
726+
JoinLinesConfig {
727+
join_else_if: self.local.joinLines_joinElseIf,
728+
remove_trailing_comma: self.local.joinLines_removeTrailingComma,
729+
unwrap_trivial_blocks: self.local.joinLines_unwrapTrivialBlock,
730+
join_assignments: self.local.joinLines_joinAssignments,
731+
}
732+
}
722733
}
723734

724735
type ParallelCachePrimingNumThreads = u8;
@@ -1661,15 +1672,6 @@ impl Config {
16611672
self.experimental("snippetTextEdit")
16621673
}
16631674

1664-
pub fn join_lines(&self) -> JoinLinesConfig {
1665-
JoinLinesConfig {
1666-
join_else_if: self.root_config.global.joinLines_joinElseIf,
1667-
remove_trailing_comma: self.root_config.global.joinLines_removeTrailingComma,
1668-
unwrap_trivial_blocks: self.root_config.global.joinLines_unwrapTrivialBlock,
1669-
join_assignments: self.root_config.global.joinLines_joinAssignments,
1670-
}
1671-
}
1672-
16731675
pub fn call_info(&self) -> CallInfoConfig {
16741676
CallInfoConfig {
16751677
params_only: matches!(

crates/rust-analyzer/src/handlers/request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ pub(crate) fn handle_join_lines(
288288
) -> anyhow::Result<Vec<lsp_types::TextEdit>> {
289289
let _p = profile::span("handle_join_lines");
290290

291-
let config = snap.config.join_lines();
292291
let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
292+
let config = snap.config.localize_by_file_id(file_id).join_lines();
293293
let line_index = snap.file_line_index(file_id)?;
294294

295295
let mut res = TextEdit::default();

0 commit comments

Comments
 (0)