Disabled autocomplete due to #166.
authorAndrey Petrov <andrey.petrov@shazow.net>
Wed, 3 Aug 2016 16:18:13 +0000 (12:18 -0400)
committerAndrey Petrov <andrey.petrov@shazow.net>
Wed, 3 Aug 2016 16:19:33 +0000 (12:19 -0400)
Also added mutex for user replyTo pointer, since that's being set by
both the host and user.

chat/message/user.go
host.go

index bcda156e1d6b8195b128b6d415aaf6dfd69f76e0..8b938d474543be3854c14035d59e7003fb20c4cb 100644 (file)
@@ -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 07af926bd0aa2e01f6a6cb613f737cc65e8fa4d2..3249cf346f3a5a7b21cd86d0fa648206c83bafcd 100644 (file)
--- 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?