fix: scrolling on suggestions

This commit is contained in:
2026-08-03 11:42:35 +02:00
parent 4f2b508154
commit 81f3f7d369
5 changed files with 125 additions and 17 deletions

View File

@@ -85,6 +85,27 @@ func TestDetailRendersSuggestionAsRemovalAndAddition(t *testing.T) {
}
}
func TestRenderedSuggestionsAreCachedWithoutSharingMutableLines(t *testing.T) {
renderedSuggestions.clear()
reviewed := []string{"old_value = compute()", "return old_value"}
first := renderSuggestion(
"example.py", reviewed, "new_value = compute()\nreturn new_value", 50,
)
if len(renderedSuggestions.entries) != 1 {
t.Fatalf("suggestion cache entries = %d, want 1", len(renderedSuggestions.entries))
}
first.removed[0].rail = "mutated"
second := renderSuggestion(
"example.py", reviewed, "new_value = compute()\nreturn new_value", 50,
)
if second.removed[0].rail != "" {
t.Fatal("caller mutation changed cached suggestion lines")
}
if len(renderedSuggestions.entries) != 1 {
t.Fatalf("cache miss for unchanged suggestion: %d entries", len(renderedSuggestions.entries))
}
}
func TestSuggestionBackgroundIsDirectionalWithoutTextUnderline(t *testing.T) {
removed := suggestionHighlight(" - ", "old", 12, '-')
added := suggestionHighlight(" + ", "new", 12, '+')