mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-19 07:25:27 +02:00
20 lines
335 B
Go
20 lines
335 B
Go
package common
|
|
|
|
// LSPCharacterAsCursorPosition:
|
|
// @deprecated
|
|
func CursorToCharacterIndex(cursor uint32) uint32 {
|
|
return max(1, cursor) - 1
|
|
}
|
|
|
|
func DeprecatedImprovedCursorToIndex(
|
|
c CursorPosition,
|
|
line string,
|
|
offset uint32,
|
|
) uint32 {
|
|
if len(line) == 0 {
|
|
return 0
|
|
}
|
|
|
|
return min(uint32(len(line)-1), uint32(c)-offset+1)
|
|
}
|