Skip to content

Commit

Permalink
Fixed autocomplete crashing bug (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
shazow committed Aug 3, 2016
1 parent a978f2c commit 13ea34b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions host.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ func (h *Host) Connect(term *sshd.Terminal) {

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

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

fields := strings.Fields(line[:pos])
isFirst := len(fields) < 2
partial := fields[len(fields)-1]
partial := ""
if len(fields) > 0 {
partial = fields[len(fields)-1]
}
posPartial := pos - len(partial)

var completed string
Expand Down

0 comments on commit 13ea34b

Please sign in to comment.