File tree Expand file tree Collapse file tree 3 files changed +25
-15
lines changed
Expand file tree Collapse file tree 3 files changed +25
-15
lines changed Original file line number Diff line number Diff line change @@ -849,19 +849,17 @@ func (h *BufPane) OutdentSelection() bool {
849849// Autocomplete cycles the suggestions and performs autocompletion if there are suggestions
850850func (h * BufPane ) Autocomplete () bool {
851851 b := h .Buf
852+ cc := buffer .AutocompleteCursorCheck (h .Cursor )
853+ rc := buffer .AutocompleteRuneCheck (h .Cursor )
852854
853855 // Don't autocomplete at all if the active cursor cannot be autocomplete
854- if ! buffer .AutocompleteCheck (h .Cursor ) {
855- return false
856- }
857-
858- if ! b .HasSuggestions && ! b .StartAutocomplete (buffer .BufferComplete ) {
856+ if ! b .HasSuggestions && (! rc || ! cc || ! b .StartAutocomplete (buffer .BufferComplete )) {
859857 return false
860858 }
861859
862860 prevSuggestion := b .CycleAutocomplete (true )
863861 for i := 0 ; i < b .NumCursors (); i ++ {
864- if buffer .AutocompleteCheck (b .GetCursor (i )) {
862+ if buffer .AutocompleteCursorCheck (b .GetCursor (i )) {
865863 b .PerformSingleAutocomplete (prevSuggestion , b .GetCursor (i ))
866864 }
867865 }
@@ -879,7 +877,7 @@ func (h *BufPane) CycleAutocompleteBack() bool {
879877 if b .HasSuggestions {
880878 prevSuggestion := b .CycleAutocomplete (false )
881879 for i := 0 ; i < b .NumCursors (); i ++ {
882- if buffer .AutocompleteCheck (b .GetCursor (i )) {
880+ if buffer .AutocompleteCursorCheck (b .GetCursor (i )) {
883881 b .PerformSingleAutocomplete (prevSuggestion , b .GetCursor (i ))
884882 }
885883 }
Original file line number Diff line number Diff line change @@ -193,11 +193,19 @@ func (h *InfoPane) CommandComplete() {
193193 b := h .Buf
194194 c := b .GetActiveCursor ()
195195
196+ cc := buffer .AutocompleteCursorCheck (c )
197+ rc := buffer .AutocompleteRuneCheck (c )
198+
196199 // Cycling commands
197- if ! buffer . AutocompleteCheck ( c ) {
200+ if ! b . HasSuggestions && ! cc && ! rc {
198201 return
199202 }
203+
200204 if b .HasSuggestions {
205+ if ! cc {
206+ return
207+ }
208+
201209 prevSuggestion := b .CycleAutocomplete (true )
202210 b .PerformSingleAutocomplete (prevSuggestion , c )
203211 return
Original file line number Diff line number Diff line change @@ -23,13 +23,7 @@ func (b *Buffer) GetSuggestions() {
2323
2424}
2525
26- func AutocompleteCheck (cursor * Cursor ) bool {
27- if cursor .HasSelection () {
28- return false
29- }
30- if cursor .X == 0 {
31- return false
32- }
26+ func AutocompleteRuneCheck (cursor * Cursor ) bool {
3327 r := cursor .RuneUnder (cursor .X )
3428 prev := cursor .RuneUnder (cursor .X - 1 )
3529 if ! util .IsAutocomplete (prev ) || util .IsWordChar (r ) {
@@ -39,6 +33,16 @@ func AutocompleteCheck(cursor *Cursor) bool {
3933 return true
4034}
4135
36+ func AutocompleteCursorCheck (cursor * Cursor ) bool {
37+ if cursor .HasSelection () {
38+ return false
39+ }
40+ if cursor .X == 0 {
41+ return false
42+ }
43+ return true
44+ }
45+
4246func (b * Buffer ) StartAutocomplete (c Completer ) bool {
4347 b .Completions , b .Suggestions = c (b )
4448 if len (b .Completions ) != len (b .Suggestions ) || len (b .Completions ) == 0 {
You can’t perform that action at this time.
0 commit comments