Skip to content

Commit

Permalink
Differentiate between full configs and toml only config groupings
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Apr 15, 2024
1 parent 67d8d2d commit 60d3a73
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 70 deletions.
8 changes: 6 additions & 2 deletions crates/ide/src/expand_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ fn _format(
use ide_db::base_db::{FileLoader, SourceDatabase};
// hack until we get hygiene working (same character amount to preserve formatting as much as possible)
const DOLLAR_CRATE_REPLACE: &str = "__r_a_";
let expansion = expansion.replace("$crate", DOLLAR_CRATE_REPLACE);
const BUILTIN_REPLACE: &str = "builtin__POUND";
let expansion =
expansion.replace("$crate", DOLLAR_CRATE_REPLACE).replace("builtin #", BUILTIN_REPLACE);
let (prefix, suffix) = match kind {
SyntaxKind::MACRO_PAT => ("fn __(", ": u32);"),
SyntaxKind::MACRO_EXPR | SyntaxKind::MACRO_STMTS => ("fn __() {", "}"),
Expand Down Expand Up @@ -206,7 +208,9 @@ fn _format(
let captured_stdout = String::from_utf8(output.stdout).ok()?;

if output.status.success() && !captured_stdout.trim().is_empty() {
let output = captured_stdout.replace(DOLLAR_CRATE_REPLACE, "$crate");
let output = captured_stdout
.replace(DOLLAR_CRATE_REPLACE, "$crate")
.replace(BUILTIN_REPLACE, "builtin #");
let output = output.trim().strip_prefix(prefix)?;
let output = match kind {
SyntaxKind::MACRO_PAT => {
Expand Down
2 changes: 1 addition & 1 deletion crates/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ always-assert = "0.2.0"
walkdir = "2.3.2"
semver.workspace = true
memchr = "2.7.1"
indexmap = { version = "2.0.0", features = ["serde"] }
indexmap = { workspace = true, features = ["serde"] }

cfg.workspace = true
flycheck.workspace = true
Expand Down
Loading

0 comments on commit 60d3a73

Please sign in to comment.