From 320de746f7a2985b60c8564a0e65bdf231e840b7 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Sep 2025 10:56:27 +0300 Subject: use gofumpt --- internal/lsp/diagnostics_action_test.go | 49 +++++++++++++++++---------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'internal/lsp/diagnostics_action_test.go') diff --git a/internal/lsp/diagnostics_action_test.go b/internal/lsp/diagnostics_action_test.go index 1a9201f..a607b86 100644 --- a/internal/lsp/diagnostics_action_test.go +++ b/internal/lsp/diagnostics_action_test.go @@ -1,30 +1,33 @@ package lsp import ( - "encoding/json" - "io" - "log" - "testing" + "encoding/json" + "io" + "log" + "testing" ) func TestHandleCodeAction_ListsDiagnosticsActionWhenOverlap(t *testing.T) { - s := &Server{logger: log.New(io.Discard, "", 0), docs: make(map[string]*document)} - s.llmClient = fakeLLM{resp: "fixed"} - uri := "file:///x.go" - s.setDocument(uri, "package p\nvar a=1\n") - // Selection overlaps line 1 - sel := Range{Start: Position{Line:1, Character:0}, End: Position{Line:1, Character:5}} - // Provide diagnostics in the action context with one overlapping - ctx := CodeActionContext{Diagnostics: []Diagnostic{ - {Range: Range{Start: Position{Line:1, Character:0}, End: Position{Line:1, Character:3}}, Message: "in"}, - {Range: Range{Start: Position{Line:0, Character:0}, End: Position{Line:0, Character:1}}, Message: "out"}, - }} - rawCtx, _ := json.Marshal(ctx) - p := CodeActionParams{TextDocument: TextDocumentIdentifier{URI: uri}, Range: sel, Context: json.RawMessage(rawCtx)} - ca := s.buildDiagnosticsCodeAction(p, "var a=1") - if ca == nil { t.Fatalf("expected diagnostics action") } - // Resolve should produce an edit - resolved, ok := s.resolveCodeAction(*ca) - if !ok || resolved.Edit == nil { t.Fatalf("expected resolved edit from diagnostics") } + s := &Server{logger: log.New(io.Discard, "", 0), docs: make(map[string]*document)} + s.llmClient = fakeLLM{resp: "fixed"} + uri := "file:///x.go" + s.setDocument(uri, "package p\nvar a=1\n") + // Selection overlaps line 1 + sel := Range{Start: Position{Line: 1, Character: 0}, End: Position{Line: 1, Character: 5}} + // Provide diagnostics in the action context with one overlapping + ctx := CodeActionContext{Diagnostics: []Diagnostic{ + {Range: Range{Start: Position{Line: 1, Character: 0}, End: Position{Line: 1, Character: 3}}, Message: "in"}, + {Range: Range{Start: Position{Line: 0, Character: 0}, End: Position{Line: 0, Character: 1}}, Message: "out"}, + }} + rawCtx, _ := json.Marshal(ctx) + p := CodeActionParams{TextDocument: TextDocumentIdentifier{URI: uri}, Range: sel, Context: json.RawMessage(rawCtx)} + ca := s.buildDiagnosticsCodeAction(p, "var a=1") + if ca == nil { + t.Fatalf("expected diagnostics action") + } + // Resolve should produce an edit + resolved, ok := s.resolveCodeAction(*ca) + if !ok || resolved.Edit == nil { + t.Fatalf("expected resolved edit from diagnostics") + } } - -- cgit v1.2.3