MCPcopy
hub / github.com/micro-editor/micro / GetArg

Method GetArg

internal/buffer/autocomplete.go:86–102  ·  view source on GitHub ↗

GetArg gets the most recent word (separated by ' ' only)

()

Source from the content-addressed store, hash-verified

84
85// GetArg gets the most recent word (separated by ' ' only)
86func (b *Buffer) GetArg() (string, int) {
87 c := b.GetActiveCursor()
88 l := b.LineBytes(c.Y)
89 l = util.SliceStart(l, c.X)
90
91 args := bytes.Split(l, []byte{' '})
92 input := string(args[len(args)-1])
93 argstart := 0
94 for i, a := range args {
95 if i == len(args)-1 {
96 break
97 }
98 argstart += util.CharacterCount(a) + 1
99 }
100
101 return input, argstart
102}
103
104// FileComplete autocompletes filenames
105func FileComplete(b *Buffer) ([]string, []string) {

Callers 7

CommandCompleteFunction · 0.80
HelpCompleteFunction · 0.80
OptionCompleteFunction · 0.80
OptionValueCompleteFunction · 0.80
PluginCmdCompleteFunction · 0.80
PluginCompleteFunction · 0.80
FileCompleteFunction · 0.80

Calls 4

GetActiveCursorMethod · 0.95
SliceStartFunction · 0.92
CharacterCountFunction · 0.92
LineBytesMethod · 0.65

Tested by

no test coverage detected