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

Method Autocomplete

internal/action/actions.go:907–930  ·  view source on GitHub ↗

Autocomplete cycles the suggestions and performs autocompletion if there are suggestions

()

Source from the content-addressed store, hash-verified

905
906// Autocomplete cycles the suggestions and performs autocompletion if there are suggestions
907func (h *BufPane) Autocomplete() bool {
908 b := h.Buf
909
910 if h.Cursor.HasSelection() {
911 return false
912 }
913
914 if b.HasSuggestions {
915 b.CycleAutocomplete(true)
916 return true
917 }
918
919 if h.Cursor.X == 0 {
920 return false
921 }
922 r := h.Cursor.RuneUnder(h.Cursor.X)
923 prev := h.Cursor.RuneUnder(h.Cursor.X - 1)
924 if !util.IsAutocomplete(prev) || util.IsWordChar(r) {
925 // don't autocomplete if cursor is within a word
926 return false
927 }
928
929 return b.Autocomplete(buffer.BufferComplete)
930}
931
932// CycleAutocompleteBack cycles back in the autocomplete suggestion list
933func (h *BufPane) CycleAutocompleteBack() bool {

Callers 1

CommandCompleteMethod · 0.45

Calls 5

IsAutocompleteFunction · 0.92
IsWordCharFunction · 0.92
CycleAutocompleteMethod · 0.80
RuneUnderMethod · 0.80
HasSelectionMethod · 0.45

Tested by

no test coverage detected