diff --git a/internal/action/actions.go b/internal/action/actions.go index 6f2f0940..9cff5de3 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -663,7 +663,12 @@ func (h *BufPane) Autocomplete() bool { return false } - if !util.IsNonAlphaNumeric(h.Cursor.RuneUnder(h.Cursor.X)) { + if h.Cursor.X == 0 { + return false + } + r := h.Cursor.RuneUnder(h.Cursor.X) + prev := h.Cursor.RuneUnder(h.Cursor.X - 1) + if !util.IsAutocomplete(prev) || !util.IsNonAlphaNumeric(r) { // don't autocomplete if cursor is on alpha numeric character (middle of a word) return false } diff --git a/internal/util/util.go b/internal/util/util.go index a63a3518..8b867ca0 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -418,6 +418,10 @@ func IsNonAlphaNumeric(c rune) bool { return !unicode.IsLetter(c) && !unicode.IsNumber(c) && c != '_' } +func IsAutocomplete(c rune) bool { + return c == '.' || !IsNonAlphaNumeric(c) +} + func ParseSpecial(s string) string { return strings.Replace(s, "\\t", "\t", -1) }