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 {
29
29
source.content.slice(source.startOfLine(start), source.nextLine(end))
30
30
31
31
/** The lines of the position */
32
- def lines : List [ Int ] = {
32
+ def lines : Range = {
33
33
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
37
37
}
38
38
39
39
def lineOffsets : List [Int ] =
40
- lines.map(source.lineToOffset(_))
40
+ lines.toList. map(source.lineToOffset(_))
41
41
42
42
def beforeAndAfterPoint : (List [Int ], List [Int ]) =
43
43
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