Autocomplete cycles the suggestions and performs autocompletion if there are suggestions
()
| 905 | |
| 906 | // Autocomplete cycles the suggestions and performs autocompletion if there are suggestions |
| 907 | func (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 |
| 933 | func (h *BufPane) CycleAutocompleteBack() bool { |
no test coverage detected