func (p Point) GoplsChar() uint32 {
	return uint32(p.utf16Col)
}
GoplsChar is the 0-index character offset in a buffer.
package types
import (
	"fmt"
	"github.com/govim/govim/cmd/govim/internal/golang_org_x_tools/lsp/protocol"
	"github.com/govim/govim/cmd/govim/internal/golang_org_x_tools/span"
)
type Point struct {
	buffer *Buffer
	line int
	col int
	offset int
	utf16Col int
}
func PointFromOffset(b *Buffer, offset int) (Point, error) {
	cc := b.tokenConvertor()
	line, col, err := cc.ToPosition(offset)
	if err != nil {
		return Point{}, fmt.Errorf("failed to calculate position within buffer %v: %v", b.Num, err)
	}
	p := span.NewPoint(line, col, offset)
	utf16col, err := span.ToUTF16Column(p, b.contents)
	if err != nil {
		return Point{}, fmt.Errorf("failed to calculate UTF16 char value: %v", err)
	}
	res := Point{
		buffer:   b,
		line:     line,
		col:      col,
		offset:   offset,
		utf16Col: utf16col - 1,
	}
	return res, nil
}
func PointFromVim(b *Buffer, line, col int) (Point, error) {
	cc := b.tokenConvertor()
	off, err := cc.ToOffset(line, col)
	if err != nil {
		return Point{}, fmt.Errorf("failed to calculate offset within buffer %v: %v", b.Num, err)
	}
	p := span.NewPoint(int(line), int(col), off)
	utf16col, err := span.ToUTF16Column(p, b.contents)
	if err != nil {
		return Point{}, fmt.Errorf("failed to calculate UTF16 char value: %v", err)
	}
	res := Point{
		buffer:   b,
		line:     line,
		col:      col,
		offset:   off,
		utf16Col: utf16col - 1,
	}
	return res, nil
}
func PointFromPosition(b *Buffer, pos protocol.Position) (Point, error) {
	cc := b.tokenConvertor()
	sline := pos.Line + 1
	scol := pos.Character
	soff, err := cc.ToOffset(int(sline), 1)
	if err != nil {
		return Point{}, fmt.Errorf("failed to calculate offset within buffer %v: %v", b.Num, err)
	}
	p := span.NewPoint(int(sline), 1, soff)
	p, err = span.FromUTF16Column(p, int(scol)+1, b.contents)
	if err != nil {
		return Point{}, fmt.Errorf("failed to translate char colum for buffer %v: %v", b.Num, err)
	}
	res := Point{
		buffer:   b,
		line:     p.Line(),
		col:      p.Column(),
		offset:   p.Offset(),
		utf16Col: int(scol),
	}
	return res, nil
}
func VisualPointFromPosition(b *Buffer, pos protocol.Position) (Point, error) {
	p, err := PointFromPosition(b, pos)
	if err != nil {
		return p, err
	}
	c := b.Contents()
	l := len(c)
	if p.Offset() == l && l > 0 && c[l-1] == '\n' {
		cc := b.tokenConvertor()
		var newLine, newCol int
		newLine, newCol, err = cc.ToPosition(l - 1)
		if err != nil {
			return p, err
		}
		p, err = PointFromVim(b, newLine, newCol)
	}
	return p, err
}
func (p Point) Buffer() *Buffer {
	return p.buffer
}
func (p Point) Line() int {
	return p.line
}
func (p Point) Col() int {
	return p.col
}
func (p Point) Offset() int {
	return p.offset
}
func (p Point) GoplsLine() uint32 {
	return uint32(p.line) - 1
}