Documentation ¶
Overview ¶
Package text implements text editing helper routines for LSP.
Index ¶
- func CutPrefix(s, prefix string) (after string, found bool)
- func DocumentURI(f AddressableFile) (uri protocol.DocumentURI, filename string, err error)
- func Edit(f File, edits []protocol.TextEdit) error
- func Position(f AddressableFile) (pos *protocol.TextDocumentPositionParams, filename string, err error)
- func ToPath(uri protocol.DocumentURI) string
- func ToURI(filename string) protocol.DocumentURI
- type AddressableFile
- type EditList
- type File
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CutPrefix ¶
CutPrefix returns s without the provided leading prefix string and reports whether it found the prefix. If s doesn't start with prefix, CutPrefix returns s, false. If prefix is the empty string, CutPrefix returns s, true.
TODO(fhs): remove and use strings.CutPrefix in Go >= 1.20
func DocumentURI ¶
func DocumentURI(f AddressableFile) (uri protocol.DocumentURI, filename string, err error)
DocumentURI returns the URI and filename of a file being edited.
func Position ¶
func Position(f AddressableFile) (pos *protocol.TextDocumentPositionParams, filename string, err error)
Position returns the current position within a file being edited.
Types ¶
type AddressableFile ¶
type AddressableFile interface { File // Filename returns the filesystem path to the file. Filename() (string, error) // CurrentAddr returns the address of current selection. CurrentAddr() (q0, q1 int, err error) }
AddressableFile represents an open file in text editor which has a current adddress.
type File ¶
type File interface { // Reader returns a reader for the entire file text buffer ("body" in acme). Reader() (io.Reader, error) // WriteAt replaces the text in rune range [q0, q1) with bytes b. WriteAt(q0, q1 int, b []byte) (int, error) // Mark marks the file for later undo. Mark() error // DisableMark turns off automatic marking (e.g. generated by WriteAt). DisableMark() error }
File represents an open file in text editor.
Click to show internal directories.
Click to hide internal directories.