rfmt 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Cargo.lock +1 -1
- data/ext/rfmt/Cargo.toml +1 -1
- data/ext/rfmt/src/format/rule.rs +47 -3
- data/lib/rfmt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4fd5d79157230ea6ee461e070a3782267196b57692c37fc0e5e06a33f2dbd6fd
|
|
4
|
+
data.tar.gz: ea5b633304e771cd80a235ae79676581791f5f1f041de4d4013fd22e60b3cd5c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1d81952b2c5b9b9a3ba04617c60c1742d6141390be0da810bdc71ab2661bd767008bf7b744b1337496035bfeab39ee9db672163f23e9d693aad681edc8236256
|
|
7
|
+
data.tar.gz: '0950ad8b8a68dc96bb20fd980751805704b6f1a6be07268210fe309ba4b6642469899f61c62d8157770956732c272636d072d9ad29d148ff555335897df2ae0e'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.6.3] - 2026-04-24
|
|
4
|
+
|
|
5
|
+
Minor stability refinements on top of the 1.6.x architecture release. See the 1.6.1 notes below for the feature set this series delivers.
|
|
6
|
+
|
|
3
7
|
## [1.6.2] - 2026-04-24
|
|
4
8
|
|
|
5
9
|
Minor stability refinements on top of the 1.6.x architecture release. See the 1.6.1 notes below for the feature set this series delivers.
|
data/Cargo.lock
CHANGED
data/ext/rfmt/Cargo.toml
CHANGED
data/ext/rfmt/src/format/rule.rs
CHANGED
|
@@ -508,8 +508,42 @@ pub fn reformat_chain_lines(
|
|
|
508
508
|
return Cow::Borrowed(source_text);
|
|
509
509
|
}
|
|
510
510
|
|
|
511
|
-
//
|
|
512
|
-
|
|
511
|
+
// Determine how much the chain is moving left. Before this pass, every
|
|
512
|
+
// `.method` line sat at some original "chain indent" (most commonly
|
|
513
|
+
// aligned under the first receiver's dot). We rewrite those lines to
|
|
514
|
+
// `base_indent + indent_width` — but that also means any multi-line
|
|
515
|
+
// *arguments* that lived inside a chain call like `.select( … )` used
|
|
516
|
+
// to be deeper than the original chain indent, and will now look
|
|
517
|
+
// orphaned off to the right if we leave them alone:
|
|
518
|
+
//
|
|
519
|
+
// @users = User.left_joins(...)
|
|
520
|
+
// .select( <- was col 17, becomes col 6
|
|
521
|
+
// 'users.*, ' \ <- still at col 19 — orphaned
|
|
522
|
+
// )
|
|
523
|
+
// .having(...)
|
|
524
|
+
//
|
|
525
|
+
// Compute the delta between the original chain indent and the new
|
|
526
|
+
// one, and shift every non-chain continuation line that lives at
|
|
527
|
+
// (or below) the original chain indent by the same amount. Lines
|
|
528
|
+
// shallower than the original chain indent (e.g. a heredoc body
|
|
529
|
+
// whose squiggly indent is measured from the terminator) are left
|
|
530
|
+
// alone, so we don't accidentally eat through them.
|
|
531
|
+
let new_chain_indent = base_indent + indent_width;
|
|
532
|
+
let chain_indent_str = " ".repeat(new_chain_indent);
|
|
533
|
+
|
|
534
|
+
let original_chain_indent = lines[1..].iter().find_map(|l| {
|
|
535
|
+
let t = l.trim_start();
|
|
536
|
+
if t.starts_with('.') || t.starts_with("&.") {
|
|
537
|
+
Some(l.len() - t.len())
|
|
538
|
+
} else {
|
|
539
|
+
None
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
let arg_shift = original_chain_indent
|
|
544
|
+
.map(|orig| orig.saturating_sub(new_chain_indent))
|
|
545
|
+
.unwrap_or(0);
|
|
546
|
+
|
|
513
547
|
let mut result = String::with_capacity(source_text.len());
|
|
514
548
|
result.push_str(lines[0].trim_end());
|
|
515
549
|
|
|
@@ -517,8 +551,18 @@ pub fn reformat_chain_lines(
|
|
|
517
551
|
result.push('\n');
|
|
518
552
|
let trimmed = line.trim();
|
|
519
553
|
if trimmed.starts_with('.') || trimmed.starts_with("&.") {
|
|
520
|
-
result.push_str(&
|
|
554
|
+
result.push_str(&chain_indent_str);
|
|
521
555
|
result.push_str(trimmed);
|
|
556
|
+
} else if arg_shift > 0 && !trimmed.is_empty() {
|
|
557
|
+
let indent = line.len() - line.trim_start().len();
|
|
558
|
+
let chain_base = original_chain_indent.unwrap_or(0);
|
|
559
|
+
if indent >= chain_base {
|
|
560
|
+
let new_indent = indent - arg_shift;
|
|
561
|
+
result.push_str(&" ".repeat(new_indent));
|
|
562
|
+
result.push_str(line.trim_start());
|
|
563
|
+
} else {
|
|
564
|
+
result.push_str(line);
|
|
565
|
+
}
|
|
522
566
|
} else {
|
|
523
567
|
// Non-chain continuation (e.g., heredoc content): preserve as-is
|
|
524
568
|
result.push_str(line);
|
data/lib/rfmt/version.rb
CHANGED