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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f1d0fa5ba56d10568e9dd3625974abc815350c4c6c2ff03d5114d8c38aae9a1
4
- data.tar.gz: 4b6256a168e7be4a70c162a26bea0983fd6397397224cd1953abbe9cc1cbd01b
3
+ metadata.gz: 4fd5d79157230ea6ee461e070a3782267196b57692c37fc0e5e06a33f2dbd6fd
4
+ data.tar.gz: ea5b633304e771cd80a235ae79676581791f5f1f041de4d4013fd22e60b3cd5c
5
5
  SHA512:
6
- metadata.gz: a90b0b5f699c21e3e5aebd5f33ce71c152694a3cc51c812d2ffda946d2250a7714ae572ab9e7538531386e09b91210aa50f5e4de49e1d11234afd6803525ede4
7
- data.tar.gz: ab5588dfe3b5035e444219ad218756b475d964f18b47fdb78311593ba964c7c4436856abca58a13fc2e799eaa7d85815e6e70be39e6d0e083d9c7951c3867553
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
@@ -1251,7 +1251,7 @@ checksum = "a96887878f22d7bad8a3b6dc5b7440e0ada9a245242924394987b21cf2210a4c"
1251
1251
 
1252
1252
  [[package]]
1253
1253
  name = "rfmt"
1254
- version = "1.6.2"
1254
+ version = "1.6.3"
1255
1255
  dependencies = [
1256
1256
  "anyhow",
1257
1257
  "clap",
data/ext/rfmt/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "rfmt"
3
- version = "1.6.2"
3
+ version = "1.6.3"
4
4
  edition = "2021"
5
5
  authors = ["fujitani sora <fujitanisora0414@gmail.com>"]
6
6
  license = "MIT"
@@ -508,8 +508,42 @@ pub fn reformat_chain_lines(
508
508
  return Cow::Borrowed(source_text);
509
509
  }
510
510
 
511
- // Build the indented chain with pre-allocated capacity
512
- let chain_indent = " ".repeat(base_indent + indent_width);
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(&chain_indent);
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rfmt
4
- VERSION = '1.6.2'
4
+ VERSION = '1.6.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfmt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - fujitani sora