Skip to content

Commit ec0352b

Browse files
committed
Use monospace font for diff hunks
Fixes misalignment issues and makes width of line numbers bar more consistent.
1 parent 7a36f86 commit ec0352b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

app/src/main/java/com/gh4a/adapter/timeline/DiffViewHolder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ public void bind(TimelineItem.Diff item) {
128128
appendLineNumber(builder, maxLineLength, rightLineText, rightLine, item, true);
129129

130130
// Add additional padding between line numbers and code
131-
builder.append(" ");
131+
builder.append(" ");
132132

133133
int lineNumberLength = builder.length() - spanStart;
134134

135-
builder.append(" ").append(lines[i]).append(" ");
135+
builder.append(" ").append(lines[i]).append(" ");
136136
if (i < lines.length - 1) {
137137
builder.append("\n");
138138
}
@@ -159,11 +159,11 @@ private void appendLineNumber(SpannableStringBuilder builder, int maxLength, Str
159159
int start = builder.length();
160160

161161
// Add padding at the start of text
162-
builder.append(" ");
162+
builder.append(" ");
163163

164164
// Right align the number if necessary
165165
for (int i = 0; i < maxLength - numberText.length(); i++) {
166-
builder.append(" ");
166+
builder.append(" ");
167167
}
168168

169169
builder.append(numberText);

app/src/main/res/layout/row_timeline_diff.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
android:id="@+id/diff_hunk"
3030
android:layout_width="wrap_content"
3131
android:layout_height="wrap_content"
32+
android:fontFamily="monospace"
3233
android:paddingBottom="@dimen/code_diff_padding"
3334
android:paddingTop="@dimen/code_diff_padding"
3435
android:textColor="?android:attr/textColorPrimary"

0 commit comments

Comments
 (0)