go-prompt/prompt/completions.go
2017-07-15 16:45:38 +09:00

25 lines
553 B
Go

package prompt
type Completion struct {
// The new string that will be inserted into document.
text string
// Position relative to the cursor position where the new text will start.
startPosition int
}
func (c *Completion) NewCompletionFromPosition(position int) *Completion {
if position < c.startPosition {
panic("position argument must be smaller than start position.")
}
return &Completion{
text: c.text[position - c.startPosition:],
}
}
func NewCompletion(text string) *Completion {
return &Completion{
text: text,
}
}