File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
compiler/src/dotty/tools/dotc/util Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -29,15 +29,15 @@ extends interfaces.SourcePosition with Showable {
2929 source.content.slice(source.startOfLine(start), source.nextLine(end))
3030
3131 /** The lines of the position */
32- def lines : List [ Int ] = {
32+ def lines : Range = {
3333 val startOffset = source.offsetToLine(start)
34- val endOffset = source.offsetToLine(end + 1 )
35- if (startOffset >= endOffset) line :: Nil
36- else ( startOffset until endOffset).toList
34+ val endOffset = source.offsetToLine(end - 1 ) // -1 to drop a line if no chars in it form part of the position
35+ if (startOffset >= endOffset) line to line
36+ else startOffset to endOffset
3737 }
3838
3939 def lineOffsets : List [Int ] =
40- lines.map(source.lineToOffset(_))
40+ lines.toList. map(source.lineToOffset(_))
4141
4242 def beforeAndAfterPoint : (List [Int ], List [Int ]) =
4343 lineOffsets.partition(_ <= point)
Original file line number Diff line number Diff line change 1+ object Test {
2+ " abc"
3+ .foo // error
4+
5+ " abc"
6+ .bar.baz // error
7+
8+ " abc"
9+ .bar // error
10+ .baz
11+ }
You can’t perform that action at this time.
0 commit comments