Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 477cf9a

Browse files
committed
Fix infinite loop, bump to version 1.2.1
1 parent 8070f7c commit 477cf9a

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66

77
## [Unreleased]
88

9+
## [1.2.1] - 2023-03-09
10+
11+
### Changed
12+
13+
- Fixed a bug where having line suffixes on the final line without a breakable could cause an infinite loop.
14+
915
## [1.2.0] - 2022-12-23
1016

1117
### Added
@@ -55,7 +61,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
5561

5662
- 🎉 Initial release! 🎉
5763

58-
[unreleased]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.2.0...HEAD
64+
[unreleased]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.2.1...HEAD
65+
[1.2.1]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.2.0...v1.2.1
5966
[1.2.0]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.1.0...v1.2.0
6067
[1.1.0]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.0.2...v1.1.0
6168
[1.0.2]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.0.1...v1.0.2

Gemfile.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
prettier_print (1.2.0)
4+
prettier_print (1.2.1)
55

66
GEM
77
remote: https://rubygems.org/
@@ -20,6 +20,7 @@ GEM
2020

2121
PLATFORMS
2222
arm64-darwin-21
23+
arm64-darwin-22
2324
x86_64-darwin-21
2425
x86_64-linux
2526

lib/prettier_print.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,11 @@ def flush(base_indentation = DEFAULT_INDENTATION)
616616
end
617617

618618
if commands.empty? && line_suffixes.any?
619-
commands += line_suffixes.sort_by(&line_suffix_sort)
620-
line_suffixes = []
619+
line_suffixes.sort_by(&line_suffix_sort).each do |(indent, mode, doc)|
620+
commands += doc.contents.reverse.map { |part| [indent, mode, part] }
621+
end
622+
623+
line_suffixes.clear
621624
end
622625
end
623626

lib/prettier_print/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
class PrettierPrint
4-
VERSION = "1.2.0"
4+
VERSION = "1.2.1"
55
end

test/prettier_print_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ class PrettierPrintTest < Test::Unit::TestCase
152152
assert_equal "content # suffix\n", result
153153
end
154154

155+
test "PrettierPrint#line_suffix without a break" do
156+
result =
157+
PrettierPrint.format do |q|
158+
q.line_suffix { q.text("# suffix") }
159+
end
160+
161+
assert_equal "# suffix", result
162+
end
163+
155164
test "PrettierPrint#trim" do
156165
result =
157166
PrettierPrint.format do |q|

0 commit comments

Comments
 (0)