Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
Ensure server doesn't panic
Browse files Browse the repository at this point in the history
  • Loading branch information
egonelbre committed Dec 26, 2018
1 parent dd6d0d4 commit b54df5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gocode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func runClients(t *testing.T, serverAddr string) {

// start bunch of clients
for i := 0; i < 10; i++ {
offset := i * 10
offset := i * 5
clientGroup.Go(func() error {
cmd := exec.CommandContext(clientCtx, "gocode",
"-sock", "tcp",
Expand All @@ -90,7 +90,7 @@ func runClients(t *testing.T, serverAddr string) {
}

// wait for a bit
time.Sleep(150 * time.Millisecond)
time.Sleep(300 * time.Millisecond)

// cancel all clients
clientCancel()
Expand Down
15 changes: 9 additions & 6 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,16 @@ func (s *Server) AutoComplete(ctx context.Context, req *AutoCompleteRequest, res
var buf bytes.Buffer
log.Printf("Got autocompletion request for '%s'\n", req.Filename)
log.Printf("Cursor at: %d\n", req.Cursor)
buf.WriteString("-------------------------------------------------------\n")
buf.Write(req.Data[:req.Cursor])
buf.WriteString("#")
buf.Write(req.Data[req.Cursor:])
log.Print(buf.String())
log.Println("-------------------------------------------------------")
if len(req.Data) > req.Cursor {
buf.WriteString("-------------------------------------------------------\n")
buf.Write(req.Data[:req.Cursor])
buf.WriteString("#")
buf.Write(req.Data[req.Cursor:])
log.Print(buf.String())
log.Println("-------------------------------------------------------")
}
}

now := time.Now()
cfg := suggest.Config{
RequestContext: ctx,
Expand Down

0 comments on commit b54df5c

Please sign in to comment.