Skip to content

Commit 42e633f

Browse files
xyJenotakustay
authored andcommitted
fix: empty file highlighting error (#225)
1 parent 090f443 commit 42e633f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Hunk/CodeCell.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,20 @@ const defaultRenderToken: DefaultRenderToken = ({type, value, markType, properti
2727
};
2828

2929
function isEmptyToken(tokens: TokenNode[]) {
30+
if (!Array.isArray(tokens)) {
31+
return true;
32+
}
33+
3034
if (tokens.length > 1) {
3135
return false;
3236
}
3337

34-
const [token] = tokens;
35-
return token.type === 'text' && !token.value;
38+
if (tokens.length === 1) {
39+
const [token] = tokens;
40+
return token.type === 'text' && !token.value;
41+
}
42+
43+
return true;
3644
}
3745

3846
export interface CodeCellProps extends HTMLAttributes<HTMLTableCellElement> {

0 commit comments

Comments
 (0)