File tree Expand file tree Collapse file tree 4 files changed +57
-18
lines changed
Expand file tree Collapse file tree 4 files changed +57
-18
lines changed Original file line number Diff line number Diff line change 4343 erb (5.0.1 )
4444 extconf_compile_commands_json (0.0.7 )
4545 ffi (1.17.2 )
46+ ffi (1.17.2-arm64-darwin )
4647 fileutils (1.7.3 )
4748 goodcheck (3.1.0 )
4849 marcel (>= 1.0 , < 2.0 )
6364 logger (1.7.0 )
6465 marcel (1.0.4 )
6566 memory_profiler (1.1.0 )
66- mini_portile2 (2.8.9 )
6767 minitest (5.25.5 )
6868 mutex_m (0.3.0 )
6969 net-protocol (0.2.2 )
7070 timeout
7171 net-smtp (0.5.1 )
7272 net-protocol
7373 nkf (0.2.0 )
74- nokogiri (1.18.8 )
75- mini_portile2 (~> 2.8.2 )
74+ nokogiri (1.18.8-arm64-darwin )
7675 racc (~> 1.4 )
7776 ostruct (0.6.1 )
7877 parallel (1.27.0 )
8685 psych (4.0.6 )
8786 stringio
8887 public_suffix (6.0.2 )
89- raap (1.2 .0 )
90- rbs (~> 3.0 )
88+ raap (1.3 .0 )
89+ rbs (~> 3.9. 0 )
9190 timeout (~> 0.4 )
9291 racc (1.8.1 )
9392 rainbow (3.1.1 )
176175 zlib (3.2.1 )
177176
178177PLATFORMS
178+ arm64-darwin-24
179179
180180DEPENDENCIES
181181 abbrev
Original file line number Diff line number Diff line change @@ -29,19 +29,24 @@ def line_count
2929
3030 def ranges
3131 @ranges ||= begin
32- lines = content . lines
33- lines << "" if content . end_with? ( "\n " )
34-
35- ranges = [ ] #: Array[Range[Integer]]
36- offset = 0
37-
38- lines . each do |line |
39- size0 = line . size
40- line = line . chomp
41- range = offset ...( offset +line . size )
42- ranges << range
43-
44- offset += size0
32+ if content . empty?
33+ ranges = [ 0 ...0 ] #: Array[Range[Integer]]
34+ lines = [ "" ]
35+ else
36+ lines = content . lines
37+ lines << "" if content . end_with? ( "\n " )
38+
39+ ranges = [ ] #: Array[Range[Integer]]
40+ offset = 0
41+
42+ lines . each do |line |
43+ size0 = line . size
44+ line = line . chomp
45+ range = offset ...( offset +line . size )
46+ ranges << range
47+
48+ offset += size0
49+ end
4550 end
4651
4752 ranges
Original file line number Diff line number Diff line change @@ -144,6 +144,21 @@ def test_each_paragraph
144144 end
145145 end
146146
147+ def test_each_paragraph__empty
148+ buffer , comments = parse_comments ( <<~RUBY )
149+ #
150+ RUBY
151+
152+ block = CommentBlock . new ( buffer , comments )
153+
154+ paragraphs = block . each_paragraph ( [ ] ) . to_a
155+
156+ paragraphs [ 0 ] . tap do |paragraph |
157+ assert_instance_of RBS ::Location , paragraph
158+ assert_equal "" , paragraph . local_source
159+ end
160+ end
161+
147162 def test_each_paragraph_colon
148163 buffer , comments = parse_comments ( <<~RUBY )
149164 # : Foo
Original file line number Diff line number Diff line change @@ -96,4 +96,23 @@ def test_sub_buffer
9696 assert_equal [ 3 , 0 ] , sub_buffer . pos_to_loc ( 6 )
9797 end
9898 end
99+
100+ def test_empty_buffer
101+ buffer = Buffer . new ( name : Pathname ( "foo.rbs" ) , content : "" )
102+
103+ assert_equal "" , buffer . content
104+ assert_equal [ "" ] , buffer . lines
105+ assert_equal [ 0 ...0 ] , buffer . ranges
106+ assert_equal "" , buffer . content
107+ end
108+
109+ def test_empty_sub_buffer
110+ buffer = Buffer . new ( name : Pathname ( "foo.rbs" ) , content : "" )
111+
112+ sub_buffer = buffer . sub_buffer ( lines : [ 0 ...0 ] )
113+ assert_equal "" , sub_buffer . content
114+ assert_equal [ "" ] , sub_buffer . lines
115+ assert_equal [ 0 ...0 ] , sub_buffer . ranges
116+ assert_equal "" , sub_buffer . content
117+ end
99118end
You can’t perform that action at this time.
0 commit comments