From 95b0a9962861b2aef4a3e9538dd38608aca4bcfc Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 16 Mar 2026 04:33:36 +0200 Subject: Document lock ordering, fix test data races, correct stateMu guard - Add doc comments clarifying Server.mu and completionState.stateMu are independent (no ordering constraint). - Fix test using wrong lock (s.mu instead of stateMu) for lastLLMCall. - Replace time.Sleep polling in 7 tests with s.inflight.Wait() to eliminate data races under -race. Co-Authored-By: Claude Opus 4.6 --- internal/lsp/triggers_config_test.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'internal/lsp/triggers_config_test.go') diff --git a/internal/lsp/triggers_config_test.go b/internal/lsp/triggers_config_test.go index dbcefd0..7ca3195 100644 --- a/internal/lsp/triggers_config_test.go +++ b/internal/lsp/triggers_config_test.go @@ -6,7 +6,6 @@ import ( "io" "log" "testing" - "time" "codeberg.org/snonux/hexai/internal/appconfig" ) @@ -75,10 +74,8 @@ func TestDetectAndHandleChat_CustomConfig_InsertsReply(t *testing.T) { s.setDocument(uri, "ok)#\n\n") out.Reset() s.detectAndHandleChat(uri) - // Give time for applyEdit request - for i := 0; i < 20 && out.Len() == 0; i++ { - time.Sleep(10 * time.Millisecond) - } + // Wait for the background chat goroutine to finish writing. + s.inflight.Wait() if out.Len() == 0 { t.Fatalf("no output written for custom chat config") } -- cgit v1.2.3