func Edit(f File, edits []protocol.TextEdit) error {
	if len(edits) == 0 {
		return nil
	}
	reader, err := f.Reader()
	if err != nil {
		return err
	}
	off, err := getNewlineOffsets(reader)
	if err != nil {
		return fmt.Errorf("failed to obtain newline offsets: %v", err)
	}
	f.DisableMark()
	f.Mark()
	for i := len(edits) - 1; i >= 0; i-- {
		e := edits[i]
		q0 := off.LineToOffset(int(e.Range.Start.Line), int(e.Range.Start.Character))
		q1 := off.LineToOffset(int(e.Range.End.Line), int(e.Range.End.Character))
		f.WriteAt(q0, q1, []byte(e.NewText))
	}
	return nil
}
Edit applied edits to file f.
package text
import (
	"fmt"
	"io"
	"github.com/fhs/acme-lsp/internal/golang_org_x_tools/span"
	"github.com/fhs/acme-lsp/internal/lsp/protocol"
)
type File interface {
	Reader() (io.Reader, error)
	WriteAt(q0, q1 int, b []byte) (int, error)
	Mark() error
	DisableMark() error
}