8000 Handle false positives in tool/auto-style.rb · ruby/ruby@985ce43 · GitHub
[go: up one dir, main page]

Skip to content

Commit 985ce43

Browse files
committed
Handle false positives in tool/auto-style.rb
1 parent 0eceb37 commit 985ce43

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tool/auto-style.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,11 @@ def with_clean_env
233233

234234
if File.fnmatch?("*.[ch]", f, File::FNM_PATHNAME) &&
235235
!DIFFERENT_STYLE_FILES.any? {|pat| File.fnmatch?(pat, f, File::FNM_PATHNAME)}
236+
orig = src.dup
236237
src.gsub!(/^\w+\([^(\n)]*?\)\K[ \t]*(?=\{$)/, "\n")
237238
src.gsub!(/^([ \t]*)\}\K[ \t]*(?=else\b)/, "\n" '\1')
238239
src.gsub!(/^[ \t]*\}\n\K\n+(?=[ \t]*else\b)/, '')
239-
indent = indent0 = true
240+
indent = indent0 = src != orig
240241
end
241242

242243
if trailing0 or eofnewline0 or expandtab0 or indent0

0 commit comments

Comments
 (0)
0