annotations

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package annotations is the store of the line annotations that extensions put after the end of lines (SPEC §10.30 "Blame", step 24.22; the Editor Decorations API of the extensions): a muted text, a theme color and a hover for a line of a document. The editors read the annotations of their document from it and are told when a document's change.

A set of annotations belongs to an owner (the extension) and a key, and holds the annotations of one document. Setting a key again replaces its set whatever its document was. The store keeps no text of the documents: lines are numbers, and an editor that shows a line the document no longer has does not draw it.

It is safe for use from several goroutines. Subscribers are called from the goroutine that made the change, after the lock is released, and must not call back into the store while they are called from a function that holds it (they do not: no lock is held).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	// Line is the line, counted from 0.
	Line int
	// Text is the text drawn after the line.
	Text string
	// Color is the id of the theme color of the text, empty for the default of the editor.
	Color string
	// Hover is the markdown of the hover, empty for none.
	Hover string
	// Link is called with the destination of a link of the hover that was clicked. Nil when the hover has no links to follow.
	Link func(dest string)
}

Annotation is a text after the end of a line.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store holds the sets of annotations. The zero value is not ready: make one with New.

func New

func New() *Store

New makes an empty store.

func (*Store) Clear

func (s *Store) Clear(owner, key string)

Clear removes the set of the owner and key.

func (*Store) ClearOwner

func (s *Store) ClearOwner(owner string)

ClearOwner removes every set of the owner (the end of its activation).

func (*Store) For

func (s *Store) For(uri string) []Annotation

For returns the annotations of the document at uri, sorted by line (the annotations of a line in the order of the owner and key of their sets).

func (*Store) Has

func (s *Store) Has(owner, key string) bool

Has tells whether the owner has a set with the key.

func (*Store) Set

func (s *Store) Set(owner, key, uri string, list []Annotation)

Set replaces the set of the owner and key with the annotations of the document at uri; an empty list removes the set. The subscribers are told the documents whose annotations changed (the old document of the set and the new one).

func (*Store) Subscribe

func (s *Store) Subscribe(fn func(uris []string)) (stop func())

Subscribe calls fn with the URIs of the documents whose annotations changed, after each change. It returns the function that stops the calls.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL