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

Method CommandComplete

internal/action/infopane.go:192–218  ·  view source on GitHub ↗

Autocomplete begins autocompletion

()

Source from the content-addressed store, hash-verified

190
191// Autocomplete begins autocompletion
192func (h *InfoPane) CommandComplete() {
193 b := h.Buf
194 if b.HasSuggestions {
195 b.CycleAutocomplete(true)
196 return
197 }
198
199 c := b.GetActiveCursor()
200 l := b.LineBytes(0)
201 l = util.SliceStart(l, c.X)
202
203 args := bytes.Split(l, []byte{' '})
204 cmd := string(args[0])
205
206 if h.PromptType == "Command" {
207 if len(args) == 1 {
208 b.Autocomplete(CommandComplete)
209 } else if action, ok := commands[cmd]; ok {
210 if action.completer != nil {
211 b.Autocomplete(action.completer)
212 }
213 }
214 } else {
215 // by default use filename autocompletion
216 b.Autocomplete(buffer.FileComplete)
217 }
218}
219
220// ExecuteCommand completes the prompt
221func (h *InfoPane) ExecuteCommand() {

Callers

nothing calls this directly

Calls 5

SliceStartFunction · 0.92
CycleAutocompleteMethod · 0.80
GetActiveCursorMethod · 0.80
LineBytesMethod · 0.65
AutocompleteMethod · 0.45

Tested by

no test coverage detected