rfmt 1.5.0 → 1.5.1

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: 2df39db6eb525d4ca6bc42d55e01057e5a12772f0b61a7a8e3101e3a8fff76ec
4
- data.tar.gz: b34bbf251457c8eb0d9174497c124f71d6a7b098ad506712acaec54812bcc674
3
+ metadata.gz: 75dbfbcc5bd176d4dc5394a718354c0d027c6ae2d855e2ee70422b3b17c91c8f
4
+ data.tar.gz: dafa925df2d12a4f055da3e03c777f96fb235eb5fde1b1d28c34ca8ba2ad110d
5
5
  SHA512:
6
- metadata.gz: 1d341d108c8875f683a2ef3654e6e540b1fe9840a4f908abc75725da544c0b8be2b27cf5534cdf634eb2e9eaaa36bed0df9500f978a6fffc95ec7379e2485cf3
7
- data.tar.gz: 9cbce53637c758998c79c77af60d10130dd293dac67c4a7918d882e816d848ef525400bd6fcebc030523a2407e08140dc1bc9227cbd9c1cfc3f579f0e5b477be
6
+ metadata.gz: 6444ec42f910b398e3129dbb9028577a9eb893de5224fcf35bd1ccc961142b6a9f33bda5f26c369ca6b8c569a5d26c166a81526c323f1cf7483d639e6e8dbc14
7
+ data.tar.gz: 4c013c8e0f7263c472c38cdbbdb12990f517e66fa5be011b9d7535ccb2cba473ba9ed958e0b5ff7fc789c693bc39c47bafa3cdfdb7bf06f6d55ba6d4b5b2e6a3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.5.1] - 2026-02-21
4
+
5
+ ### Fixed
6
+ - Fix inline modifier `if`/`unless` formatting (#87)
7
+ - Fix heredoc command incorrectly removed (#90, #86)
8
+ - Fix method chain command dependency handling (#89, #85)
9
+
10
+ ### Added
11
+ - Heredoc comment deletion support
12
+ - Place block loop emission support
13
+
14
+ ### Changed
15
+ - Update README.md
16
+ - Code formatting improvements (RuboCop compliance)
17
+
3
18
  ## [1.5.0] - 2026-01-25
4
19
 
5
20
  ### Added
data/Cargo.lock CHANGED
@@ -1214,7 +1214,7 @@ checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
1214
1214
 
1215
1215
  [[package]]
1216
1216
  name = "rfmt"
1217
- version = "1.5.0"
1217
+ version = "1.5.1"
1218
1218
  dependencies = [
1219
1219
  "anyhow",
1220
1220
  "clap",
data/README.md CHANGED
@@ -23,6 +23,7 @@ A Ruby code formatter written in Rust
23
23
  ## What is rfmt?
24
24
 
25
25
  [RubyGems reference](https://rubygems.org/gems/rfmt)
26
+ [DeepWiki rfmt](https://deepwiki.com/fs0414/rfmt)
26
27
 
27
28
  **rfmt** is a Ruby code formatter that enforces consistent style across your codebase. Key characteristics:
28
29
 
data/ext/rfmt/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "rfmt"
3
- version = "1.5.0"
3
+ version = "1.5.1"
4
4
  edition = "2021"
5
5
  authors = ["fujitani sora <fujitanisora0414@gmail.com>"]
6
6
  license = "MIT"
@@ -1000,6 +1000,7 @@ impl Emitter {
1000
1000
  self.write_source_text(predicate)?;
1001
1001
  }
1002
1002
 
1003
+ self.emit_trailing_comments(node.location.end_line)?;
1003
1004
  return Ok(());
1004
1005
  }
1005
1006
 
@@ -1035,6 +1036,7 @@ impl Emitter {
1035
1036
  }
1036
1037
  }
1037
1038
 
1039
+ self.emit_trailing_comments(node.location.end_line)?;
1038
1040
  return Ok(());
1039
1041
  }
1040
1042
 
@@ -1196,6 +1198,16 @@ impl Emitter {
1196
1198
  if let Some(text) = self.source.get(start..end) {
1197
1199
  // Trim trailing whitespace but preserve the content
1198
1200
  write!(self.buffer, "{}", text.trim_end())?;
1201
+
1202
+ // Mark comments within the extracted range as emitted
1203
+ for (idx, comment) in self.all_comments.iter().enumerate() {
1204
+ if !self.emitted_comment_indices.contains(&idx)
1205
+ && comment.location.start_offset >= start
1206
+ && comment.location.end_offset <= end
1207
+ {
1208
+ self.emitted_comment_indices.insert(idx);
1209
+ }
1210
+ }
1199
1211
  }
1200
1212
  }
1201
1213
 
@@ -125,16 +125,14 @@ module Rfmt
125
125
  end
126
126
  end
127
127
 
128
- # Check child nodes for heredoc (e.g., LocalVariableWriteNode containing StringNode)
129
- node.child_nodes.compact.each do |child|
130
- next unless child.respond_to?(:closing_loc) && child.closing_loc
131
-
132
- closing = child.closing_loc
133
- next unless closing.end_offset > end_offset
134
-
135
- end_offset = closing.end_offset
136
- end_line = closing.end_line
137
- end_column = closing.end_column
128
+ # Recursively check all descendant nodes for heredoc closing_loc
129
+ # Issue #74: handled direct children (e.g., LocalVariableWriteNode -> StringNode)
130
+ # Issue #86: handles deeper nesting (e.g., CallNode -> ArgumentsNode -> StringNode)
131
+ max_closing = find_max_closing_loc_recursive(node)
132
+ if max_closing && max_closing[:end_offset] > end_offset
133
+ end_offset = max_closing[:end_offset]
134
+ end_line = max_closing[:end_line]
135
+ end_column = max_closing[:end_column]
138
136
  end
139
137
 
140
138
  {
@@ -147,6 +145,32 @@ module Rfmt
147
145
  }
148
146
  end
149
147
 
148
+ # Recursively find the maximum closing_loc among all descendant nodes
149
+ # Returns nil if no closing_loc found, otherwise { end_offset:, end_line:, end_column: }
150
+ def self.find_max_closing_loc_recursive(node, depth: 0)
151
+ return nil if depth > 10
152
+
153
+ max_closing = nil
154
+
155
+ node.child_nodes.compact.each do |child|
156
+ if child.respond_to?(:closing_loc) && child.closing_loc
157
+ closing = child.closing_loc
158
+ if max_closing.nil? || closing.end_offset > max_closing[:end_offset]
159
+ max_closing = {
160
+ end_offset: closing.end_offset,
161
+ end_line: closing.end_line,
162
+ end_column: closing.end_column
163
+ }
164
+ end
165
+ end
166
+
167
+ child_max = find_max_closing_loc_recursive(child, depth: depth + 1)
168
+ max_closing = child_max if child_max && (max_closing.nil? || child_max[:end_offset] > max_closing[:end_offset])
169
+ end
170
+
171
+ max_closing
172
+ end
173
+
150
174
  # Extract child nodes
151
175
  def self.extract_children(node)
152
176
  children = []
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.5.0'
4
+ VERSION = '1.5.1'
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.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - fujitani sora