@@ -36,7 +36,7 @@ import (
3636)
3737
3838func GetDistance (text string , start Position , pos Position ) int {
39- lines := utils .CountLinesCached (text )
39+ lines := utils .CountLinesPooled (text )
4040 defer utils .PutCount (lines )
4141 // find the line of the position
4242 return (* lines )[pos .Line - start .Line ] + pos .Character - start .Character
@@ -59,12 +59,23 @@ func RelativePostionWithLines(lines []int, textPos Position, pos Position) int {
5959 return lines [l ] + pos .Character - textPos .Character
6060}
6161
62+ func PositionOffsetIdentified (uri string , text string , pos Position ) int {
63+ if pos .Line < 0 || pos .Character < 0 {
64+ log .Error ("invalid text position: %+v" , pos )
65+ return - 1
66+ }
67+ lines := utils .CountLinesCached (uri , text )
68+ defer utils .PutCount (lines )
69+
70+ return RelativePostionWithLines (* lines , Position {Line : 0 , Character : 0 }, pos )
71+ }
72+
6273func PositionOffset (text string , pos Position ) int {
6374 if pos .Line < 0 || pos .Character < 0 {
6475 log .Error ("invalid text position: %+v" , pos )
6576 return - 1
6677 }
67- lines := utils .CountLinesCached (text )
78+ lines := utils .CountLinesPooled (text )
6879 defer utils .PutCount (lines )
6980
7081 return RelativePostionWithLines (* lines , Position {Line : 0 , Character : 0 }, pos )
0 commit comments