From c4604fde9458d17c91de813915b4ebe722bb86b7 Mon Sep 17 00:00:00 2001
From: Andrey Petrov <andrey.petrov@shazow.net>
Date: Wed, 3 Aug 2016 12:18:13 -0400
Subject: [PATCH] Disabled autocomplete due to #166.

Also added mutex for user replyTo pointer, since that's being set by
both the host and user.
---
 chat/message/user.go | 8 +++++++-
 host.go              | 3 ++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/chat/message/user.go b/chat/message/user.go
index bcda156..8b938d4 100644
--- a/chat/message/user.go
+++ b/chat/message/user.go
@@ -28,9 +28,11 @@ type User struct {
 	done     chan struct{}
 	Ignored  *common.IdSet
 
-	replyTo   *User // Set when user gets a /msg, for replying.
 	screen    io.WriteCloser
 	closeOnce sync.Once
+
+	mu      sync.Mutex
+	replyTo *User // Set when user gets a /msg, for replying.
 }
 
 func NewUser(identity Identifier) *User {
@@ -62,11 +64,15 @@ func (u *User) SetId(id string) {
 
 // ReplyTo returns the last user that messaged this user.
 func (u *User) ReplyTo() *User {
+	u.mu.Lock()
+	defer u.mu.Unlock()
 	return u.replyTo
 }
 
 // SetReplyTo sets the last user to message this user.
 func (u *User) SetReplyTo(user *User) {
+	u.mu.Lock()
+	defer u.mu.Unlock()
 	u.replyTo = user
 }
 
diff --git a/host.go b/host.go
index 07af926..3249cf3 100644
--- a/host.go
+++ b/host.go
@@ -120,7 +120,8 @@ func (h *Host) Connect(term *sshd.Terminal) {
 
 	// Successfully joined.
 	term.SetPrompt(GetPrompt(user))
-	term.AutoCompleteCallback = h.AutoCompleteFunction(user)
+	// FIXME: Re-enable once https://github.com/shazow/ssh-chat/issues/166 is fixed.
+	//term.AutoCompleteCallback = h.AutoCompleteFunction(user)
 	user.SetHighlight(user.Name())
 
 	// Should the user be op'd on join?