Add tests for double-width characters at the edges of a view

If a double-width character starts in the last column of a view that
doesn't wrap, its second half is drawn over the view's frame. If one is
scrolled halfway out to the left, the column it still reaches into isn't
drawn at all. This column then has neither the selection highlight nor
the line's background. Both happen in every view that doesn't wrap: the
side panels, and the main view with gui.wrapLinesInDiffView set to
false.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Stefan Haller
2026-10-10 13:35:25 +02:00
co-authored by Claude Opus 5.5
parent 7fc43006c0
commit bab90de2fd
+48
View File
@@ -1166,6 +1166,54 @@ func TestResizingAWrappingViewKeepsItsPlaceInTheContent(t *testing.T) {
assert.Equal(t, []string{"another wrapping line"}, v.SelectedLines())
}
// A double-width character that starts in the last column doesn't fit, and shows as a
// blank there rather than reaching into the frame.
func TestDoubleWidthCharacterAtTheRightEdge(t *testing.T) {
WithSimulationScreen(t, 14, 6)
v := NewView("name", 0, 0, 11, 5, OutputNormal) // InnerWidth 10
v.writeString("abcdefghiプ\n")
v.draw(true)
// The frame puts view column 9 at screen column 10.
chr, _, width := Screen.Get(10, 1)
/* EXPECTED:
assert.Equal(t, " ", chr)
assert.Equal(t, 1, width)
ACTUAL: */
assert.Equal(t, "プ", chr)
assert.Equal(t, 2, width)
}
// A double-width character that is scrolled halfway out to the left shows as a blank
// in the column it still reaches into, so that the column is drawn like every other.
func TestDoubleWidthCharacterCutOffAtTheLeftEdge(t *testing.T) {
WithSimulationScreen(t, 14, 6)
v := NewView("name", 0, 0, 11, 5, OutputNormal) // InnerWidth 10
v.Highlight = true
v.SelBgColor = ColorBlue
v.writeString("にプ\n")
v.SetOriginX(1)
v.draw(true)
// The frame puts view column 0 at screen column 1.
chr, style, _ := Screen.Get(1, 1)
assert.Equal(t, " ", chr)
assert.Equal(t,
/* EXPECTED:
true,
ACTUAL: */
false,
style.GetBackground() != tcell.ColorDefault,
"the selection covers the column")
chr, _, _ = Screen.Get(2, 1)
assert.Equal(t, "プ", chr)
}
// The inclusion gutter reserves columns at the left of every line, draws its marker
// on the marked lines only, and moves the content out of the way.
func TestInclusionGutter(t *testing.T) {