Skip to content

Commit 13ea34b

Browse files
committed
Fixed autocomplete crashing bug (#166)
1 parent a978f2c commit 13ea34b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

host.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ func (h *Host) Connect(term *sshd.Terminal) {
120120

121121
// Successfully joined.
122122
term.SetPrompt(GetPrompt(user))
123-
// FIXME: Re-enable once https://github.com/shazow/ssh-chat/issues/166 is fixed.
124-
//term.AutoCompleteCallback = h.AutoCompleteFunction(user)
123+
term.AutoCompleteCallback = h.AutoCompleteFunction(user)
125124
user.SetHighlight(user.Name())
126125

127126
// Should the user be op'd on join?
@@ -220,7 +219,10 @@ func (h *Host) AutoCompleteFunction(u *message.User) func(line string, pos int,
220219

221220
fields := strings.Fields(line[:pos])
222221
isFirst := len(fields) < 2
223-
partial := fields[len(fields)-1]
222+
partial := ""
223+
if len(fields) > 0 {
224+
partial = fields[len(fields)-1]
225+
}
224226
posPartial := pos - len(partial)
225227

226228
var completed string

0 commit comments

Comments
 (0)