fix(app): keep diff gutter row aligned when line number is blank
The recently added numberOfLines={1} on the gutter <Text> wraps the
content in display:-webkit-box; overflow:hidden on web, where a plain
ASCII space collapses to zero height. That shifted every line number up
by one row, leaving "1" next to the hunk marker. Use a non-breaking
space so the cell keeps its line height.
This commit is contained in:
@@ -8,7 +8,11 @@ import {
|
||||
|
||||
describe("diff-rendering", () => {
|
||||
it("keeps header gutters tall even when they do not show a line number", () => {
|
||||
expect(formatDiffGutterText(null)).toBe(" ");
|
||||
// Must be a non-collapsing whitespace: the gutter <Text> uses
|
||||
// numberOfLines={1}, which on web wraps in display:-webkit-box;
|
||||
// overflow:hidden. A plain ASCII space collapses to zero height
|
||||
// there and shifts every line number up by one row.
|
||||
expect(formatDiffGutterText(null)).toBe("\u00A0");
|
||||
expect(formatDiffGutterText(82)).toBe("82");
|
||||
});
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@ interface HighlightLikeToken {
|
||||
}
|
||||
|
||||
// Preserve row height when a gutter or diff cell is intentionally blank.
|
||||
// Non-breaking space because the gutter <Text> uses numberOfLines={1}, which
|
||||
// collapses a plain ASCII space to zero height on web.
|
||||
export function formatDiffGutterText(lineNumber: number | null): string {
|
||||
return lineNumber == null ? " " : String(lineNumber);
|
||||
return lineNumber == null ? "\u00A0" : String(lineNumber);
|
||||
}
|
||||
|
||||
export function formatDiffContentText(content: string | null | undefined): string {
|
||||
|
||||
Reference in New Issue
Block a user