Take empty arrays into account to break down chunks
Previous implementation assumed 'a' and 'b' to be
undefined, but not empty array.
Change-Id: I7a339d839b0645612f666de973f5563f0c0d6af0
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor.ts b/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor.ts
index c3d758c..5a432dd 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor.ts
@@ -679,15 +679,18 @@
*/
_breakdownChunk(chunk: DiffContent): DiffContent[] {
let key: 'a' | 'b' | 'ab' | null = null;
- if (chunk.a && !chunk.b) {
+ const {a, b, ab, move_details} = chunk;
+ if (a?.length && !b?.length) {
key = 'a';
- } else if (chunk.b && !chunk.a) {
+ } else if (b?.length && !a?.length) {
key = 'b';
- } else if (chunk.ab) {
+ } else if (ab?.length) {
key = 'ab';
}
- if (!key) {
+ // Move chunks should not be divided because of move label
+ // positioned in the top of the chunk
+ if (!key || move_details) {
return [chunk];
}